Basic Joomla Component File Structure


Joomla Component Setup

Joomla components are built to use within the Joomla frontend and backend. One folder within the administrator folder is used to display the component when logged into the administrator backend while another folder is located inside the components folder. Bot folders contain the name of the component; such as as com_componentname. However, the frontend files can include files from the administrator folder. The excerpt below shows the basic structure of a component.

BACKEND

DEFINE TOOLBARS
administrator/components/com_componentname/toolbar.componentname.html.php

DECIDE WHICH TOOLBAR TO DISPLAY
administrator/components/com_componentname/toolbar.componentname.php

BACKEND DISPLAY
administrator/components/com_componentname/controller.php
Contains component functions like public, show entries, edit, publish, save and delete

BACKEND DISPLAY
administrator/components/com_componentname/admin.componentname.php
-puts the files together
-includes files like the html file (admin.componentname.html), adds tables, instantiates the controller object and displays

default task

BACKEND DISPLAY
administrator/components/com_componentname/admin.componentname.html.php
-contains HTML_componentname class and html code for functions like editReview, showReviews, etc

FRONTEND

START
components/componentname/componentname.php
-loads tables, includes controller and instantiates the controller object, dislays default task like view all

components/componentname/controller.php
-uses display() function
-displays requested view and corresponding model
-Normally, one var is all entries and the other is a single entry with one id. Code is below to display desired view.
Jrequest::getVar('view', 'all');

router.php
-used to give adequate views and ids

VIEWS FOLDER
-contains folders for views; such as all or a single view. The folder must not use the name view or an error will trigger.
- view files within subfolders are named view.html

All Entries
class ComponentnameViewSubfoldername extends JView {

Single Entries
class ComponentnameViewSubfoldername extends JView {

MODELS FOLDER
-contains models for a single revue or all the revues
-class name is class ModelComponentnameFilename extends JModel
-Model and and view will have matching names