Basics of Component Development in Joomla!
- The
file structure for Joomla component is as under.
- Consider
a component com_hello:
- Controller.php
- Controllers
- Controller1.php
- Controller2.php
- Hello.php
- Models
- Views
- Hello
- Tmpl
- View.html.php
- Index.html
- Index.html
- This
is the basic file structure for a component in joomla.
- Controller.php
is the main controller and one can add controllers for specific purposes in the
‘controllers’ folder.
- The
file hello.php will instantiate a controller object of a class named HelloController.
Joomla will look for the declaration of that class in an aptly named file
called controller.php (it's a default behavior).
- Models as we know takes care of data, which is written in hello.php inside 'models' folder.
- In
the views part, we have a folder named ‘tmpl’, which contains default.php, which is the view used by
joomla by default unless we specify one. And it uses the default template set
by us for the site.
- The
component for site and admin part can be thought of as two different
components, based on the functionality required at the two parts.
- The
files for both these can kept in site
and admin folders respectively in
case they are different components, and if they have some common files no need
to make two folders and put all in one folder com_hello. Hence the zip file that we install contains these two
folders and a .xml file that describes which files goes to admin part and which
ones to the site part during the installation of extension.
No comments:
Post a Comment