Joomla Day India 2009 Business Logic With The MvcPresentation Transcript
Building Custom Components in Joomla 1.5
Executive Director of GMITC
Explain how to implement your business logic using a custom Joomla! component;
Introduce to the Joomla MVC and other system resources;
Demonstrate some code.
The purpose of this presentation is to:
Do you need an extension?
How many people ... ?
Already have Joomla Websites?
Use Joomla 3PD extensions?
Want an extension that doesn't ( yet ) exist?
Are developers, have developers, or will hire developers to create an extension?
What is an extension?
A Joomla! Extension ...
Implements your business logic,
Does not alter the Joomla core, so that you can easily perform upgrades,
Should ( but does not have to ) use the Joomla Framework.
Why Write an Extension
You may wish to write an extension if you have specific business logic that an existing extension does not perform or does not perform the task as you need.
Examples of Extension Tasks
Displaying customer information.
Placing an order
Entering information about a person
Checking the status of an application
Changing a client's request
Sending a notification
many more ... ( this is where I ask for suggestions )
Extensions in the Joomla Framework
Components - Interactive screens representing business logic.
Modules - Displayed in specific areas of a template.
Plugins - Extend the Joomla Framework.
It is easy to implement business logic using custom extensions.
Joomla 1.5's MVC
Software Design Pattern
Business, presentation, and control logic are separate
You can change one part without affecting another ( yay ! )
Joomla 1.5 is the first version of Joomla that uses a MVC design pattern ( double yay ! )
What is an MVC
Model - The model is the part of the component that encapsulates the application’s data and business logic – it does the work.
View - The view is the part of the component that is used to render the data from the model using a layout file – it creates the interface.
Controller - The controller will determine what request has been made by the user and respond appropriately using the model and view – it controls who does what and when.
Components implement custom business logic rules.
You may need to write your own component to express business logic specific to you.
Joomla 1.5 provides an MVC to help you write a component.
Implementing the Simplest Component 1. Create the directory JOOMLA/components/com_hello/ 2. Create the file JOOMLA/components/com_hello/hello.php 3. Add the following code to the file <?php echo 'Hello World' ?> 4. Execute the following SQL query insert into jos_components values ( NULL, 'Hello', '', 0, 0, '', '', 'com_hello', 0, '', 0, '', 1 ); 5. Access the page using the following URL index.php?option=com_hello
New to the MVC?
The Joomla Dev Website offers a sample hello component that you can experiment with.
File System Layout
Files that you will see in the hello tutorial once installed.