JController and its subclass usage overview

From Joomla! Documentation

Revision as of 23:27, 19 January 2011 by Mrs.siam (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In Joomla! 1.6, there are lots of improvement for MVC. These improvements made developer task easier. In Joomla! 1.5, there is only one class for Controller named JController. In Joomla! 1.6, there are JControllerAdmin and JControllerForm as sublcass of JController. So there is a different usage for these three classes in Joomla! component development. This is a pattern used by most of Joomla! core components such as com_content, com_banners etc.

If you look at com_content backend, you will found two places for controller classes. The first one is in the root folder of component and the second one is in controllers folder. In the root folder there is a file named controller.php, this is a master controller of the component. It is a directly subclass of JController. In controllers folder, there are many files named according to entities in the component e.g. article and articles. These controllers subclass from JControllerAdmin or JControllerForm.