CMS & Blog Templates

WordPress - Joomla - Mambo - Drupal - Php-Nuke
home >Joomla Tutorials >Joomla Components
What is Joomla? How to install Joomla? Joomla Installation
Manual installation Joomla Administration Joomla Media Manager
Joomla Content Joomla Sections Joomla Categories
Joomla Content Items Manage Banner Ads Joomla Polls
Joomla Extensions Joomla and VirtueMart Joomla and SMF
Joomla and Calendar Joomla AdSense Joomla Components
Gallery2 and Joomla Joomla Backup Joomla 1.0 Upgrade
Joomla 1.0 to 1.5 Upgrade Expose Gallery for Joomla Joomla 1.5 Tutorial
Other Tutorials

Joomla Components


Introduction
In this tutorial we will try to give you some general info on starting a Joomla component development. After reading this article you should get some thoughts about making a component.

Before you begin
If you never tried to make a Joomla component before, it would be good to explain a few things.

Joomla is an open-source project which means you can peak into every file to find out how someone else did something you want to do. At first it could be confusing to fully understand the code because of objects and their methods, variables and constants. The important thing to keep in mind is that your component is just a php file as any other you made before. There is no limitations you need to worry about when you develop your component. How will you organize your code is up to you. But following Joomla coding guidelines is recommended as you will one day distribute your component or maybe other people will be interested in joining you in the project. Before you try to code some functions yourself, try to find out is there Joomla class that does the same thing (for example pop-up calendar).

Preparation
To begin development of a new component it is a good practice to create an empty component and install it on your Joomla site. You also must have full ftp or direct access to Joomla directory. If your Joomla site is located on your computer than you don't have to worry about this. To work via ftp you need an application that is capable of doing so (Zend Development Enviroment for example). ZDE is a great tool for PHP coders. It is not free, but it's worth every cent. Using it, you can add ftp server, to server list and that work directly on ftp server like you work on local disk. That can save you a lot of time and frustration.

It is recommended to read a tutorial on creating a installation package.
Now that you installed an empty component you can start with development.

Organizing code

When Joomla executes your component it looks in the "com_componentname" directory, strips away the "com_" and executes "componentname.php" file.
That file is the base for all activities your component will perform. You can put all the code into that single file, but if you intend to make a component that will be maintainable in the future you should try to separate the code into logical parts. You can have as many files and folders as you need to (note that the more files you have the more work you will need to spend creating installation package).

Also it is a good practice to separate html presentation from component logic. If you've read 'hello world' tutorial from dev.joomla.org than you could see that you are encouraged to organize a code that way.

Public vs Administration

Almost every component needs some kind of administration which will be available trough Joomla administration interface. Writing a single component is in fact witting two separate components that use the same tables. One will be installed and run from components folder, and other will be installed and run from administrator/components folder.

Writing administrative part of component can be a bit more difficult at first, as you should try to use Joomla classes so that your component administration looks as close as possible to other components.
Also, beside database items that your component uses, you should consider making a configuration panel so that component administrator can customize component features ( e.g. number of items that will be displayed for each page in result list, fields that will be displayed ).

Testing and Debugging

If you are developing component on you local server or on a server with php error display directive turned on, testing and debugging is not a problem. But typically on a production server ( e.g. hosting package you rent for your Joomla site ) when you have error in your code, php will stop execution but will not display error message. Also, you can have bugs in your component which will not stop the execution, but will display undesired results. That is why you should plan to build a debug system in your component from the start.

The easiest way is to create a session variable ( e.g. $_SESSION["debug"] ) that turns debuging on/off. You can start debug mode by adding debug=on in the url params ( e.g. index.php?option=com_test&debug=on ). Every time you start a session in you component you can check if the debug param has been passed and if so turn debug mode on.

session_start(); 
if (isset($_REQUEST["debug"])) {
    if ($_REQUEST["debug"] == "on") $_SESSION["debug"] = true;
    if ($_REQUEST["debug"] == "off") $_SESSION["debug"] = false;
}
function debug_Log($message) {
    if ($_REQUEST["debug"]) {
       echo "<br>Debug: ".$message."<br>";
    }

The more you use the function ( and more data you put in the $message variable ) that will be easier to correct errors and bugs.

Summary
We hope that you now have some guidelines on developing components from Joomla. The idea for this article was to give information that you would learn yourself after a few tryouts on making a component on your own.

Joomla Templates Free Joomla Templates Joomla Hosting
Joomla Themes Joomla Components Joomla FAQ
Joomla Tutorials Joomla Directory Joomla Resources
Free Joomla Themes
Free Joomla Themes available here is basically a ready-made design representing a typical high-quality and beautiful design of all of the CMS and Blog Drupal Themes.
   
Customize Joomla Templates
Joomla templates customization services you can easily get a unique and professional looking website that will correspond to your business needs.
   
Best Joomla Hosting
Are looking for the best Joomla web hosting? A good web host for Joomla that we can suggest which is available on the web.
   
Best Joomla Books
Are looking for the best Joomla books? Here we have some good collection of books about Joomla available on the web, which can be used for beginner or intermidiate developers.
 

» Joomla Templates
» Free Joomla Templates
» Joomla Hosting
» Joomla Themes
» Joomla Components
» Joomla FAQ
» Joomla Tutorials
» Joomla Directory
» Joomla Resources
» Joomla Books
» Joomla Videos
» Joomla Templates Customization

All joomla templates are completely customizable and ready for immediate download.

Template Types
» Turnkey Websites
» Premium Templates
» Flash Templates
» PowerPoint Templates
» Personal Pages Templates
» Most Popular
» Low Budget Templates
» Flash Photo Galleries
» Corporate Identity
» Last Added Templates
» Zero Downloads
» CSS Web Templates
» PhpBB3
» PhpBB2
» phpBB Skins
» Web 2.0 Templates
» Forums Web Templates
» Portals Web Templates
» Flash Intro Templates
» SWiSH Templates
» Zencart Templates
» CRE Loaded Templates
» osCommerce Templates
» Halloween Web
» XML Flash Site Templates
» Magento Templates

 Template Categories
Click here for more Categories


Web Templates | WordPress Themes | PHP-Nuke Themes | Joomla Templates | Mambo Templates | Drupal Themes | phpBB Templates | Flash Web Templates |
Dynamic flash photo gallery templates | osCommerce Templates | CRE Loaded Templates | CSS Web Templates | XML Sitemap | SWiSH Templates |
Real Estate Templates | Site Map | Web Templates Customization | Website Builder | Affiliate Program | Resources | Templates Directory
Copyright © 2003 -2009 CMS & Blog Templates. All Right Reserved. FAQ | Terms of Use  Web Design by Digital Dreams - Your Outsource Partner