Joomla Components and Modules
New Joomla users often have a problem when defining “Component” and “Module” terms. But once difference between these two terms becomes clear understanding of Joomla architecture becomes more exact as well. So, what is the difference between module and component?
There is the simple answer: module can appear on any page and has a quite simple structure. While component is loaded on its own page and as a rule has more difficult structure.
This answer is quite enough to bate one’s curiosity. And if you need more detailed answer, let’s begin from the description of how Joomla loads pages.
When somebody enters your site, he runs index.php file from Joomla folder. This file loads different classes and other code elements which allow Joomla working. After this Joomla finds folder of the current template and tries to load index.php from there. So, index.php file is contained in the root folder as well as in the template folder and root index.php loads index.php for template.
index.php for template usually looks like a typical HTML file. You will find the following string there:
<?php include_once(‘mainbody.php’); ?>
This string pauses recording of HTML strings and launches code from mainbody.php which loads one component. This means that every Joomla page loads a component. (You can remove this string. In this case Joomla will not loading of components and your site will lose a lot of its functionality). By default Joomla will load a component correlated with the first menu item. Usually it is ‘Home’ which indicates to the ‘frontpage’ component. As a rule it contains links to news articles. As soon as you click the link, ‘content’ component will be loaded together with the article. Other links load other components.
In addition to the mainbody.php template contains calls of mosLoadModules() functions, for example mosLoadModules(‘left’);.This function loads all modules attached to the current component to the left of the screen (by default the screen is divided into the following areas: left, top, bottom, inset, user1, user2). After making module configurations the select list will appear in the Joomla back-end allowing to attach this module to some components. There is no need to use templates for loading of modules to all positions. But they will be useful for loading at least one module and leave some place for menu until you’ll set its location. Usually users of your site are not worried about difference between module and component. Nevertheless site administrators should know how to control these elements. Modules are installed/uninstalled in modules submenu.
If you click the ‘Manage Modules’ item another list will appear providing options of publishing/unpublishing, positioning and location. This list can be longer than the first one because of user modules. These modules are stored in database as articles. But in other respects they don’t differ from the rest of modules.
All modules can have some parameters. This allows to change module settings without creating a complex interface for site administrators. For example, if a developer wishes to give administrator ability to change module background he can add the respective parameter to module management. Administrator will click header of the module and will be able to enter, for example, backgroundcolor = green to the ‘Parameters’ table.
Development of administrative side of a component requires for considerable time costs. But the result is easy to use interface. When loading component’s administrative side, admin.[component_name].php file is executed from /administrator/components/ folder.