Building a Joomla Component – Setting Up the Basic Structure

 

Setting up the Directory Structure

The first step in building a Joomla! component is to set up the basic directory structure and files to support it.  There is a /components directory located in the root Joomla installation folder.  This folder contains files and other folders pertaining to the front end (what web site visitors see) of your component.  Also located in the root folder of your Joomla! installation is a folder setup like this: /administrator/components.  This is the folder where your back end administration files and folders go.  The naming convention used for the folder where a Joomla! component actually exists is com_mycomponent, where mycomponent is the name of the component.

 

When the component is called from the backend or from the front end, the Joomla framework automatically looks for a unique .php file named after the component.  An example will help illustrate this setup:

 

If I were developing a mortgage calculator (mortcalc), I would use the following directory setup

            [joomla_installation]/components/com_mortcalc/mortcalc.php

            [joomla_installation]/administrator/components/com_mortcalc/mortcalc.php

 

Registering Your Component in the Joomla! Database

To create access to your component from the Joomla! administrator navigation menus, you need to register the component in the Joomla database.  This is done by making an entry in the jos_components table.  If you setup your Joomla! database so that it uses a table prefix other than jos_, your components table name will obviously be slightly different.  The pertinent fields from that table, which you’ll need to specify when making your component entry, are name, link, admin_menu_link, and option.  These fields set up the Joomla! internal navigation for your component so that it can be referenced from the Components menu and so that it can be linked to on the frontend from a Joomla! menu using the standard component link.

 

After you have executed the SQL (either with an SQL statement or using a graphical interface) to register your component, you will then see it listed under the Components menu of the Joomla! administrator section.  The value you entered in the name field will be the name that shows up on the Components menu.

 

Moving Forward
With these two steps behind you, all that’s left to do is code the functionality of your Joomla! component, right?  Obviously there is a lot of work ahead now that you’ve set up the basic structure.  To make the most of your component and the Joomla! extension framework, you should familiarize yourself with the Joomla! extension classes.  Joomla! provides class structures and a development framework that simplify performing such tasks as creating toolbars, handling the logic between your database, the administrator setup, and providing a useful experience for end users of your component.

Leave a Reply

Your email address will not be published. Required fields are marked *