Documente Academic
Documente Profesional
Documente Cultură
Documentation
25/06/12
navigation
Main Page Recent changes Current events Random page Brow se categories Help
Components in Jooomla! 1.5 can now benefit from the flexibility and power of using Object Oriented Programming (OOP) practices. Most complex components will follow the ModelView-Controller (MVC) design pattern. This pattern separates the data gathering (Model), presentation (View) and user interaction (Controller) activities of a component. Such separation allows for expanding or revising properties and methods of one section without requiring additional changes to the other sections. Please see the MVC tutorial for an explanations of the MVC structure. Joomla!'s file loading system enables developers to work with separate files for controllers, views and models without worrying about importing the right file in the right place. However, for this to work, certain naming conventions need to be observed. The Joomla! framework is extremely flexible, and it is possible to diverge from these conventions in many ways. It is nonetheless recommended to apply standard naming wherever possible to increase readability and maintainability. Additionally, the framework will take care of the many tedious class management tasks when the files and classes of a component are named correctly. Throughout this article, {ComponentName} is used to represent the name of the component (for example, Content). Notice also that case is important. {componentname} will refer to the lowercase version of {ComponentName}, eg. CamelCasedController ->
camelcasedcontroller.
search
Go
Search
joomla! sites
Main Community Forum Extensions Shop Developers API
toolbox
What links here Related changes Special pages Printable version Permanent link
Reserved words
There are reserved words which can't be used in names of classes and components. An example is the word "view" (in any case) for view classes (except "view" that must be second part of that class name)[1]. Because the first part of the name of view classes is the same as the controller class name, controller class names can't contain the word "view" either. And because of the conventions (although violating of it won't produce an error), controller class names must contain the component name, so component names can't contain the word "view" either. So components can't be named "com_reviews", or if they are, they must violate the naming conventions and have a different base controller class name (or have some other hacks).
If you set up your XML manifest file according to standard practice, the contents of site will be installed to /components/com_{componentname}, whereas the contents of admin will be installed to /administrator/components/com_{componentname}.
25/06/12
/site/{componentname}.php
This is the component's main file and entry point for the frontend part.
/site/controller.php
This file holds the default frontend controller, which is a class called {ComponentName}Controller. This class must extend the base class JController.
/site/views
This file is the entry point for the view {ViewName}. It should declare the class {ComponentName}View{ViewName}. This class must extend the base class
JView.
The .html section of the filename is related to the format the view will
be loaded in. For example, if the format URL parameter is set to format=feed, the file view.feed.php will be loaded.
/site/views/{viewname}/tmpl
This folder holds the template files for the view {ViewName}.
/site/views/{viewname}/tmpl/default.php
This is the default template for the view {ViewName}. In this PHP file, the $this keyword refers to the view class that the template belongs to.
/site/models
This file holds the model class extend the base class
JModel.
{ComponentName}Model{ModelName}.
default load a model called {ViewName} if it exists. Most models are named after the view they are intended to be used with, but this is not a requirement. See Using multiple models in an MVC component for more information.
/site/controllers
{ComponentName}Controller{ControllerName}. JController.
http://docs.joomla.org/Naming_conventions
2/3
25/06/12
http://docs.joomla.org/Naming_conventions
3/3