<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Datashuttle</id>
	<title>Joomla! Documentation - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Datashuttle"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/Datashuttle"/>
	<updated>2026-09-19T05:33:42Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=API16:JParameter/_construct&amp;diff=38236</id>
		<title>API16:JParameter/ construct</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=API16:JParameter/_construct&amp;diff=38236"/>
		<updated>2011-04-04T14:53:07Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
Constructor&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;editsection&amp;quot; style=&amp;quot;font-size:76%;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;[[Description:JParameter/__construct|Edit Descripton]]&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Description:JParameter/__construct}}&lt;br /&gt;
&lt;br /&gt;
===Syntax===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;__construct($data= &#039;&#039;, $path= &#039;&#039;)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Parameter Name&lt;br /&gt;
!Default Value&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
| $data&lt;br /&gt;
| &#039;&#039;&lt;br /&gt;
|  The raw params text &lt;br /&gt;
|-&lt;br /&gt;
| $path&lt;br /&gt;
| &#039;&#039;&lt;br /&gt;
|  Path to the xml setup file &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Defined in===&lt;br /&gt;
libraries/joomla/html/parameter.php&lt;br /&gt;
===Importing===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;jimport( &#039;joomla.html.parameter&#039; );&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Source Body===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
public function __construct($data = &#039;&#039;, $path = &#039;&#039;)&lt;br /&gt;
{&lt;br /&gt;
        parent::__construct(&#039;_default&#039;);&lt;br /&gt;
&lt;br /&gt;
        // Set base path.&lt;br /&gt;
        $this-&amp;gt;_elementPath[] = dirname(__FILE__).DS.&#039;parameter&#039;.DS.&#039;element&#039;;&lt;br /&gt;
&lt;br /&gt;
        if ($data = trim($data)) {&lt;br /&gt;
                if (strpos($data, &#039;{&#039;) === 0) {&lt;br /&gt;
                        $this-&amp;gt;loadJSON($data);&lt;br /&gt;
                } else {&lt;br /&gt;
                        $this-&amp;gt;loadINI($data);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        if ($path) {&lt;br /&gt;
                $this-&amp;gt;loadSetupFile($path);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        $this-&amp;gt;_raw = $data;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;editsection&amp;quot; style=&amp;quot;font-size:76%;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;[[SeeAlso:JParameter/__construct|Edit See Also]]&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
{{SeeAlso:JParameter/__construct}}&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&amp;lt;CodeExamplesForm /&amp;gt;&lt;br /&gt;
&amp;lt;dpl&amp;gt;&lt;br /&gt;
 noresultsheader=\n&lt;br /&gt;
 category=__construct&lt;br /&gt;
 category=JParameter&lt;br /&gt;
 category=CodeExample&lt;br /&gt;
 category=MethodExample&lt;br /&gt;
 include=*&lt;br /&gt;
 format= ,,,&lt;br /&gt;
&amp;lt;/dpl&amp;gt;&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36906</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36906"/>
		<updated>2011-02-09T21:17:48Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and therein lies a &#039;problem&#039;: Whether you pass a request or not, Joomla! will use its defaults to complete a request, making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do a request that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a method (function) named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are methods in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute method call. But in order to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system, it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views, you have to call the display() method of JController. Do this by inserting, in your method, a call to parent::display() as in the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder for your views. This means that you need to create a views folder with a hierarchy that looks like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
   controller.php&lt;br /&gt;
   &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
   &#039;views&#039; folder&lt;br /&gt;
      view1 folder&lt;br /&gt;
      view2 folder&lt;br /&gt;
      ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view folder. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request, you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or, if you did not include it, you need to include it now because there is no such a thing as a default view. So your URL is something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very little effort from you, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As mentioned before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal, you will need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules mentioned before. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36905</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36905"/>
		<updated>2011-02-09T21:12:27Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and therein lies a &#039;problem&#039;: Whether you pass a request or not, Joomla! will use its defaults to complete a request, making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do a request that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a method (function) named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are methods in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute method call. But in order to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system, it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views, you have to call the display() method of JController. Do this by inserting, in your method, a call to parent::display() as in the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder for your views. This means that you need to create a views folder with a hierarchy that looks like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
   controller.php&lt;br /&gt;
   &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
   &#039;views&#039; folder&lt;br /&gt;
      view1 folder&lt;br /&gt;
      view2 folder&lt;br /&gt;
      ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view folder. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request, you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or, if you did not include it, you need to include it now because there is no such a thing as a default view. So your URL is something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very little effort from you, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As mentioned before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36895</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36895"/>
		<updated>2011-02-08T23:40:04Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and therein lies a &#039;problem&#039;: Whether you pass a request or not, Joomla! will use its defaults to complete a request, making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do a request that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a method (function) named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are methods in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute method call. But in order to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system, it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views, you have to call the display() method of JController. Do this by inserting, in your method, a call to parent::display() as in the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder for your views. This means that you need to create a views folder with a hierarchy that looks like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
   controller.php&lt;br /&gt;
   &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
   &#039;views&#039; folder&lt;br /&gt;
      view1 folder&lt;br /&gt;
      view2 folder&lt;br /&gt;
      ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view folder. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request, you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or, if you did not include it, you need to include it now because there is no such a thing as a default view. So your URL is something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36894</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36894"/>
		<updated>2011-02-08T23:37:59Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete a request, making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do a request that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a method (function) named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are methods in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute method call. But in order to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system, it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views, you have to call the display() method of JController. Do this by inserting, in your method, a call to parent::display() as in the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder for your views. This means that you need to create a views folder with a hierarchy that looks like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
   controller.php&lt;br /&gt;
   &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
   &#039;views&#039; folder&lt;br /&gt;
      view1 folder&lt;br /&gt;
      view2 folder&lt;br /&gt;
      ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view folder. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request, you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or, if you did not include it, you need to include it now because there is no such a thing as a default view. So your URL is something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36893</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36893"/>
		<updated>2011-02-08T23:35:45Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete a request, making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do a request that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a method (function) named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are methods in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute method call. But in order to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system, it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views, you have to call the display() method of JController. Do this by inserting, in your method, a call to parent::display() as in the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder for your views. This means that you need to create a views folder with a hierarchy that looks like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
   controller.php&lt;br /&gt;
   &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
   &#039;views&#039; folder&lt;br /&gt;
      view1 folder&lt;br /&gt;
      view2 folder&lt;br /&gt;
      ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view folder. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36892</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36892"/>
		<updated>2011-02-08T23:34:13Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete a request, making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do a request that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a method (function) named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are methods in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute method call. But in order to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system, it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views, you have to call the display() method of JController. Do this by inserting, in your method, a call to parent::display() as in the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder for your views. This means that you need to create a views folder with a hierarchy that looks like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
   controller.php&lt;br /&gt;
   &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
   &#039;views&#039; folder&lt;br /&gt;
      view1 folder&lt;br /&gt;
      view2 folder&lt;br /&gt;
      ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36891</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36891"/>
		<updated>2011-02-08T23:32:59Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete a request, making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do a request that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a method (function) named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are methods in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute method call. But in order to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system, it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views, you have to call the display() method of JController. Do this by inserting, in your method, a call to parent::display() as in the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder for your views. This means that you need to create a views folder with a hierarchy that looks like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
 controller.php&lt;br /&gt;
 &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
 &#039;views&#039; folder&lt;br /&gt;
    view1 folder&lt;br /&gt;
    view2 folder&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36890</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36890"/>
		<updated>2011-02-08T23:30:45Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete a request, making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do a request that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a method (function) named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are methods in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute method call. But in order to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system, it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views, you have to call the display() method of JController. Do this by inserting, in your method, a call to parent::display() as in the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder for your views. This means that you need to create a views folder with a hierarchy that looks like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
 controller.php&lt;br /&gt;
 &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
 &#039;views&#039; folder&lt;br /&gt;
 view1&lt;br /&gt;
 view2&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36889</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36889"/>
		<updated>2011-02-08T22:09:06Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete a request, making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do a request that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a method (function) named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are methods in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute method call. But in order to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system, it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views, you have to call the display() method of JController. Do this by inserting, in your method, a call to parent::display() as in the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder of your views. This means that you have to create the views folder and now you could have something like in your disk:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
 controller.php&lt;br /&gt;
 &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
 &#039;views&#039; folder&lt;br /&gt;
 view1&lt;br /&gt;
 view2&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36888</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36888"/>
		<updated>2011-02-08T22:05:35Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete a request, making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do a request that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a method (function) named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are methods in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute method call but to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views you only have to call the display() method of JController. You do this by inserting in your method a call to parent::display() as the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder of your views. This means that you have to create the views folder and now you could have something like in your disk:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
 controller.php&lt;br /&gt;
 &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
 &#039;views&#039; folder&lt;br /&gt;
 view1&lt;br /&gt;
 view2&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36887</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36887"/>
		<updated>2011-02-08T22:03:29Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete a request, making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do a request that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a method (function) named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are functions in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute method call but to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views you only have to call the display() method of JController. You do this by inserting in your method a call to parent::display() as the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder of your views. This means that you have to create the views folder and now you could have something like in your disk:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
 controller.php&lt;br /&gt;
 &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
 &#039;views&#039; folder&lt;br /&gt;
 view1&lt;br /&gt;
 view2&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36886</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36886"/>
		<updated>2011-02-08T21:51:33Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete a request, making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do a request that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a function named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are functions in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute function call but to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views you only have to call the display() function of JController. You do this by inserting in your function a call to parent::display() as the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder of your views. This means that you have to create the views folder and now you could have something like in your disk:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
 controller.php&lt;br /&gt;
 &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
 &#039;views&#039; folder&lt;br /&gt;
 view1&lt;br /&gt;
 view2&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36885</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36885"/>
		<updated>2011-02-08T21:49:37Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete a request, making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do the request that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a function named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are functions in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute function call but to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views you only have to call the display() function of JController. You do this by inserting in your function a call to parent::display() as the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder of your views. This means that you have to create the views folder and now you could have something like in your disk:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
 controller.php&lt;br /&gt;
 &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
 &#039;views&#039; folder&lt;br /&gt;
 view1&lt;br /&gt;
 view2&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36884</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36884"/>
		<updated>2011-02-08T21:47:45Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete a request, making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do the requested job that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a function named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are functions in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute function call but to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views you only have to call the display() function of JController. You do this by inserting in your function a call to parent::display() as the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder of your views. This means that you have to create the views folder and now you could have something like in your disk:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
 controller.php&lt;br /&gt;
 &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
 &#039;views&#039; folder&lt;br /&gt;
 view1&lt;br /&gt;
 view2&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36883</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36883"/>
		<updated>2011-02-08T21:44:32Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, what you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete one making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do the requested job that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a function named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are functions in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute function call but to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views you only have to call the display() function of JController. You do this by inserting in your function a call to parent::display() as the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder of your views. This means that you have to create the views folder and now you could have something like in your disk:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
 controller.php&lt;br /&gt;
 &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
 &#039;views&#039; folder&lt;br /&gt;
 view1&lt;br /&gt;
 view2&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36882</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36882"/>
		<updated>2011-02-08T21:43:46Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful where you put your files, how you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete one making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do the requested job that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a function named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are functions in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute function call but to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views you only have to call the display() function of JController. You do this by inserting in your function a call to parent::display() as the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder of your views. This means that you have to create the views folder and now you could have something like in your disk:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
 controller.php&lt;br /&gt;
 &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
 &#039;views&#039; folder&lt;br /&gt;
 view1&lt;br /&gt;
 view2&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36881</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36881"/>
		<updated>2011-02-08T21:43:14Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful as where you put your files, how you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call come from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete one making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do the requested job that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a function named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are functions in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute function call but to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views you only have to call the display() function of JController. You do this by inserting in your function a call to parent::display() as the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder of your views. This means that you have to create the views folder and now you could have something like in your disk:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
 controller.php&lt;br /&gt;
 &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
 &#039;views&#039; folder&lt;br /&gt;
 view1&lt;br /&gt;
 view2&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36880</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36880"/>
		<updated>2011-02-08T21:40:31Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes yourself. (Well, only one file and only one class actually, but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically, so you must be careful as where you put your files, how you name them and what classes you define, because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call comes from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete one making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do the requested job that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a function named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are functions in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute function call but to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views you only have to call the display() function of JController. You do this by inserting in your function a call to parent::display() as the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder of your views. This means that you have to create the views folder and now you could have something like in your disk:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
 controller.php&lt;br /&gt;
 &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
 &#039;views&#039; folder&lt;br /&gt;
 view1&lt;br /&gt;
 view2&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36879</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36879"/>
		<updated>2011-02-08T20:08:30Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: Changed some of the wording to be consistant with second-person narrative&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that you have controller.php included and the base JController class imported, you have to define a class that extends the JController base class. This is the class leg you wrote before about and it is here where your action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage you have your first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. The next step is to create an object of this class and to put it to work. So add these lines to your base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes by yourself. (Well, only one file and only one class actually but you could do it!) From now on the Joomla! framework will begin loading your files and calling your classes automatically so you must be careful as where you put your files, how you name them and what classes you define because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But you have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call comes from? Do you really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete one making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do the requested job that, in this case, will be the default task &#039;display&#039;, because you have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a function named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now you have delved with the controller part of the model. This is a new point of decision. You can stop here or go a step further and enter the view part. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and your different tasks are functions in the controller.php file. Arguments are lost but all the needed variables are available from the framework so you will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces you to use the &#039;task&#039; variable to drive the call because you can pass the value of any variable as the parameter to the execute function call but to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views you only have to call the display() function of JController. You do this by inserting in your function a call to parent::display() as the last line. At a minimum, your controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder of your views. This means that you have to create the views folder and now you could have something like in your disk:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
 controller.php&lt;br /&gt;
 &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
 &#039;views&#039; folder&lt;br /&gt;
 view1&lt;br /&gt;
 view2&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy, I know, so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view, you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have formats other than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal you need some code inside the view.&amp;lt;format&amp;gt;.php file. You have the view file, now you need the view class. You have to extend the JView class with your own class following the strict rules, mentioned before, that you should follow. In this case, your class name must be built by concatenating the component name, the word &#039;View&#039;, and the view name. So your class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must answer. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But you can go a bit further. Up to this point you have a distributed framework that dissects your request in such a way that allow you to create small and very specific files to react only to specific types of requests. In this way the files that you must process can be very small and adjusted to the situation you are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point you can dissect a bit more and have another layer of detail: the final layout for the data you deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that you have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36876</id>
		<title>Absolute Basics of How a Component Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=36876"/>
		<updated>2011-02-08T19:44:18Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: Changed word from this to these&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Some weeks ago I was asked to confirm if a custom PHP web development with a high budget was the right path to follow. After having a look at the goals of the project I thought that the custom path was overkill and told him that I believed that any open source CMS customization could deliver the same for lot less money. Having made a selection a year or so before I recommended Joomla! as the right tool for the job expecting that my paper will end at this point. But I finally got involved.&lt;br /&gt;
&lt;br /&gt;
The only weak point of Joomla! at the time I made my selection (version 1.x) was that is was slow because of the huge joomla.php library file but I thought when making my recommendation that the new hardware we have now would compensate.&lt;br /&gt;
&lt;br /&gt;
But to my surprise the Joomla! 1.5.2 framework had just been released and a first look at it was promising. The problem was that there is very little, if any information at all about how the pieces that Joomla! connect with each other. After developing a component, a module and a plugin to achieve the goals of the project, I had to look at lots of disparate small documents, source code and tantra to learn how these pieces work together to make the new Joomla! 1.5. It&#039;s a fabulous environment to develop web solutions in an easy and powerful way. My congratulations to the development group that has been able to envision such a magnificent tool.&lt;br /&gt;
&lt;br /&gt;
This document is my attempt to express to the community what I have learned while developing the project and also learn from the feedback and help from others. Because I am quite sure that there are lots of things that need revision I humbly request the help of the Joomla! gurus out there to take the time to read this somehow long dissertation and feed me with their knowledge. And, not less important, I request your tolerance if my English is not Oxford-like because I am not a native English speaking person. Luckily, this is a wiki, and others have come by to help with some editing.&lt;br /&gt;
&lt;br /&gt;
Ok. Let&#039;s start...&lt;br /&gt;
&lt;br /&gt;
You enter the Joomla! framework by making calls to index.php. Joomla! is designed mainly to deliver the results of component files. When you call a page link like index.php?option=com_&amp;lt;name&amp;gt; the Joomla! framework tries to find and load the file components/com_&amp;lt;name&amp;gt;/&amp;lt;name&amp;gt;.php from whatever the folder you have installed Joomla! into. So if your component is &#039;com_read&#039; you should have a &#039;com_read&#039; folder and a file named &#039;read.php&#039; inside of it. I will call this file the &#039;base file&#039; and it is in this file where you make the decision whether to use an old flat model (returning the HTML code for the requested page) or to use a Model-View-Controller (MVC) pattern.&lt;br /&gt;
&lt;br /&gt;
This MVC model, walks over two legs: a file and a class. The Joomla! framework will usually look for a given file and if found, tries to register a specific class within this file. If either one is missing the call fails.&lt;br /&gt;
&lt;br /&gt;
You start all the fireworks by including a controller file in your base file. The controller file can be named anything you want, but by convention it is called &#039;controller.php&#039;. In your base file (&amp;lt;name&amp;gt;.php), the following code is typical:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once(JPATH_COMPONENT.DS.&#039;controller.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your controller.php file can be created anywhere you want because we are including it by path but if you have written exactly the former line it should be created in the same location where your base file is located because JPATH_COMPONENT holds the path where the executing component base file is and DS represents the path separator translated to whatever is convenient for your OS, being it windows or linux.&lt;br /&gt;
&lt;br /&gt;
So create controller.php and make a reference to the controller library inside by importing it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that we have controller.php included and the base JController class imported, we have to define a class that extend the JController base class. This is the class leg we wrote before about and it is here where our action will happen. You can name this class as you like but, by convention, it is named after your component so you write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this stage we have our first two files, the base file and the controller file. The base file loads the controller and the controller defines a class. So far so good and easy. Our next step is to create an object of this class and to put it to work. So we add these lines to our base file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create the controller&lt;br /&gt;
$controller = new &amp;lt;name&amp;gt;Controller(); or whatever the name you gave your controller class&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this point on things start happening by themselves. Up to now you were able to name files, except for the base one, and put them where you wanted, and name classes like you wanted because you were including the files by path/name and calling your classes by yourself. (Well, only one file and only one class actually but you could do it!) From now the Joomla! framework will begin loading your files and calling your classes automatically so you must be careful as where we put our files, how we name them and what classes we define because a single letter mismatch will make Joomla! fail.&lt;br /&gt;
&lt;br /&gt;
Where does the Joomla! framework get the data to play?. Well, the answer is easy: from the request, be it a GET request or a POST request. But we have NOT written anything else in the request except option=com_&amp;lt;name&amp;gt;. Where does the &#039;task&#039; in the execute call comes from? Do we really have a meaningful &#039;task&#039; variable?&lt;br /&gt;
&lt;br /&gt;
Yes, and this is the &#039;problem&#039;: Whether you pass or do not pass a full request, Joomla! will use its defaults to complete one making some errors difficult to spot.&lt;br /&gt;
&lt;br /&gt;
The controller-&amp;gt;execute() call will make the Joomla! framework try to do the requested job that, in this case, will be the default task &#039;display&#039;, because we have not specified otherwise.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;displaying&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So that if your request contained a &#039;task=jump&#039; parameter the controller would have tried to call a function named jump in your controller class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function jump()&lt;br /&gt;
{&lt;br /&gt;
echo &#039;jumping&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Up to now we have delved with the controller part of the model. This is a new point of decision. We can stop here or we can go a step further and enter the view part of it. Stopping here will, at least, simplify your base file over Joomla! 1.1.x . Up to version 1.5, components usually had a switch statement that, depending on the given task (or whatever passed variable), called a function with several arguments to deliver the HTML result.&lt;br /&gt;
&lt;br /&gt;
With Joomla! 1.5, the switch is gone and our different tasks are functions in the controller.php file. Arguments are lost but all the needed variables are available from the framework so we will be able to retrieve them easily.&lt;br /&gt;
&lt;br /&gt;
There is nothing that forces us to use the &#039;task&#039; variable to drive the call because we can pass the value of any variable as the parameter to the execute function call but to stick to the non-written rules, &#039;task&#039; is usually used (and as it is treated specially by the system it is a good idea to stick with it).&lt;br /&gt;
&lt;br /&gt;
To trigger the views we only have to call the display() function of JController. We do this by inserting in our function a call to parent::display() as the last line. At the minimum our controller file should contain the following: (?Is this necessary? The display function should be pulled from the JController class that it is extending, right?)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
class &amp;lt;name&amp;gt;Controller extends JController&lt;br /&gt;
{&lt;br /&gt;
function display()&lt;br /&gt;
{&lt;br /&gt;
parent::display();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What&#039;s a view?&#039;&#039;&#039;&lt;br /&gt;
A view is a subset of data. It&#039;s the same concept as views in SQL parlance. You deliver different parts of your data with different views. So you could have a detailed data view and a resumed data view, the later presenting a subset of the whole data presented in the former.&lt;br /&gt;
&lt;br /&gt;
As you can have multiple views Joomla! uses the &#039;views&#039; folder in your component&#039;s base directory to keep things tidy. This folder is only a placeholder of your views. This means that you have to create the views folder and now you could have something like in your disk:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;name&amp;gt; base folder&lt;br /&gt;
 controller.php&lt;br /&gt;
 &amp;lt;component_name&amp;gt;.php&lt;br /&gt;
 &#039;views&#039; folder&lt;br /&gt;
 view1&lt;br /&gt;
 view2&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Inside the views folder other folders hold the files that build each view. The Joomla! framework includes a file named view.html.php that should exist in your view directory. A bit messy I know so I&#039;ll try to explain.&lt;br /&gt;
&lt;br /&gt;
When you built your request you included a variable named &#039;view&#039; that tells the MVC model what view you want. Or if you did not include it you better include it now because there is not such a thing like a default view. So your URL was something like:&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;[&amp;amp;task=&amp;lt;mytask&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
The task part may or may not exist. Remember that if you omit it you are defaulting to task=display. With this URL Joomla! is importing a file located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/view.html.php. If this files or the path does not exist, Joomla! will fail. By simply swapping the value of the view you deliver different views of your data.&lt;br /&gt;
&lt;br /&gt;
Every request for a view requires that you also specify the format you are serving the view. There exist several well known formats such as html (the default one if none is specified), rss, etc. but you can use your own. If no format is specified in the request with the &#039;format=&amp;lt;myformat&amp;gt;&#039; parameter a default value of &#039;html&#039; is used.&lt;br /&gt;
&lt;br /&gt;
The &#039;html&#039; format makes the Joomla! framework wrap the response in whatever template your site is using so that you get a fully built HTML page. This way, with very few effort from you side, you get back your page fully loaded with modules or whatever you had configured.&lt;br /&gt;
&lt;br /&gt;
The specific format you are using is what you have written in the middle part of the name of the file in your view folder (The file we talked about a few lines before &#039;view.html.php&#039;). If you use a different format like &#039;rss&#039; your file should be named after it like view.rss.php. Get it?&lt;br /&gt;
&lt;br /&gt;
As told before, you can have other formats than html and Joomla! will not wrap the template on them. You could have a &#039;pdf&#039; format to deliver your data in pdf format or even an &#039;ajax&#039; format to deliver ajax responses to the front-end easily. Just construct your URL like&lt;br /&gt;
&lt;br /&gt;
http://example.com/index.php?option=com_&amp;lt;name&amp;gt;&amp;amp;view=&amp;lt;myview&amp;gt;&amp;amp;format=ajax&lt;br /&gt;
&lt;br /&gt;
to make the Joomla! Framework look for and load the file view.ajax.php located at &amp;lt;site root dir&amp;gt;/components/&amp;lt;name&amp;gt;/views/&amp;lt;myview&amp;gt;/ from where you can echo anything you want. It&#039;s that easy.&lt;br /&gt;
&lt;br /&gt;
Anyway, to achieve your goal we need some code inside the view.&amp;lt;format&amp;gt;.php file. We have the view file, now we need the view class. You have to extend the JView class with your own following the strict rules we said before that we should follow. In this case, your class name must be build by concatenating the component name, the word &#039;View&#039;, and the view name. So our class name will be a capitalized &amp;lt;name&amp;gt;View&amp;lt;myview&amp;gt;. If your component is named travels and your view is named detail (URL ...?option=com_read&amp;amp;view=detail) your view class must be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class TravelsViewDetail extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
echo &#039;blah, blah&#039;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within this class you only have to feed the data you want to display for your component under this specific case. You can do this directly by delivering the [x]HTML code directly, or through calls to echo inside php tags, or be more subtle and use a layout (more on this later).&lt;br /&gt;
&lt;br /&gt;
Can you have other functions besides display? I don&#039;t know. This is something that the gurus must respond. Where does the display function come from? Again, I don&#039;t know. Hope that someone else can help here.&lt;br /&gt;
&lt;br /&gt;
But we can go a bit further. Up to this point we have a distributed framework that dissects our request in such a way that allow us to create small and very specific files to react only to specific types of requests. In this way the files that we must process can be very small and adjusted to the situation we are treating, speeding up the global response time of the system by not loading lots of code that will not ever be used with this kind of requests (as in Joomla! 1.x).&lt;br /&gt;
&lt;br /&gt;
Having reached this point we can dissect a bit more and have another layer of detail: the final layout for the data we deliver.&lt;br /&gt;
&lt;br /&gt;
A layout is a way to present the data for the view. The same data can be delivered under different visual aspects so that the same preparation code (inside the display function of your view class) can present the same data in different ways simply using different files. You &#039;inject&#039; the view data in the layout template and use the template code to visually format it for presenting to the user.&lt;br /&gt;
&lt;br /&gt;
As before, if you do not specify a layout you go with the &#039;default&#039; layout. To use layouts you need to create a new folder under the related view folder named &#039;tmpl&#039; and create a file named &amp;lt;mylayout&amp;gt;.php, nothing more nothing less. If you are using the default layout this file will be named &#039;default.php&#039;.&lt;br /&gt;
&lt;br /&gt;
The desired layout can be specified in the request by means of a &#039;layout=&amp;lt;mylayout&amp;gt;&#039; variable or can be injected in the call if you manage to get the layout you want to use from other sources.&lt;br /&gt;
&lt;br /&gt;
To use a layout your view class must call &#039;parent::display();&#039; and pass the layout template name as a parameter. So your class should be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class &amp;lt;Name&amp;gt;View&amp;lt;Viewname&amp;gt; extends JView&lt;br /&gt;
{&lt;br /&gt;
function display($tpl=null)&lt;br /&gt;
{&lt;br /&gt;
// Prepare the data&lt;br /&gt;
$data1 = ....&lt;br /&gt;
$data2 = ....&lt;br /&gt;
$moredata[] = array....&lt;br /&gt;
&lt;br /&gt;
// Inject the data&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename&#039;, $data1);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename2&#039;, $data2);&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;variablename3&#039;, $moredata);&lt;br /&gt;
&lt;br /&gt;
// Call the layout template&lt;br /&gt;
$tpl = &#039;myTemplate&#039;;&lt;br /&gt;
parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
or more directly&lt;br /&gt;
&lt;br /&gt;
parent::display(&#039;myTemplate&#039;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This way Joomla! will look for a file named &#039;myTemplate.php&#039; in the &#039;tmpl&#039; folder of the given view. Inside this template file you get a &#039;$this&#039; object that has access to the variables you have injected by means of &#039;$this-&amp;gt;variablename&#039; that you can use in your constructions to deliver your [x]HTML *FINAL* code.&lt;br /&gt;
&lt;br /&gt;
As you surely will have determined by this moment by yourself you can have different layouts files in your tmpl folder thus driving easily your output with simple, small, very specific files.&lt;br /&gt;
&lt;br /&gt;
If you have been observant you will have noticed that we have not &#039;used&#039; the &#039;model&#039; part of MVC model. Here you have the last point of decision. You can go without this part or apply fully the model but I think I will keep this tale for another session. For sure I have already abused of my audience.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Chunk:Framework_(CMS_1.5_and_1.6)&amp;diff=36738</id>
		<title>Chunk:Framework (CMS 1.5 and 1.6)</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Chunk:Framework_(CMS_1.5_and_1.6)&amp;diff=36738"/>
		<updated>2011-02-04T13:40:09Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: Removed the word &amp;quot;its&amp;quot; in the second paragraph&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
[[Image:Joomla_Architecture.jpg|thumb|The Joomla Architecture]]&lt;br /&gt;
&lt;br /&gt;
The Joomla Framework is an important part of the Joomla architecture. It&#039;s based on modern object-oriented design patterns that make the Joomla core highly maintainable and easily extendable ([[About the Joomla Framework|Learn more about the Joomla Framework]]). &lt;br /&gt;
&lt;br /&gt;
Third party developers benefit from the rich, and easily accessible functionality that the Joomla Framework provides. On this page we&#039;d like to provide you a reference of all classes and respective methods. The links will take you to further information about each class including, where possible, examples of use.&lt;br /&gt;
&lt;br /&gt;
If you would like to help us improve this resource, please read [[API Reference Project]].&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J1.5:Component_parameters&amp;diff=36732</id>
		<title>J1.5:Component parameters</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J1.5:Component_parameters&amp;diff=36732"/>
		<updated>2011-02-03T22:57:28Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: /* 2. Menu item specific parameters */ Added missing word to second paragraph.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background==&lt;br /&gt;
One thing that sets Joomla! Components apart from other types of Extension (i.e. Modules and Plugins) is the ability to store significant quantities of data in the Joomla! MySQL database.  Typically, this data will be content for displaying on a page (such as the content of an article, or its title) or data about how that content should be displayed (e.g. a setting specifying whether or not the title should be shown).  A Component normally creates at least one table in the database to store this data - for example, data for articles associated with the &amp;lt;code&amp;gt;com_content&amp;lt;/code&amp;gt; Component are stored in the &amp;lt;code&amp;gt;jos_content&amp;lt;/code&amp;gt; table (where &#039;&#039;jos&#039;&#039; is the table prefix for the site).&lt;br /&gt;
&lt;br /&gt;
However, choosing exactly how to store each item of data requires a little more thought.  There are essentially two choices:  each data item may be stored in its own field, or a collection of data items may be stored within a single parameters field.  (Of course, there is nothing to stop you making use of both methods, for different data items, within the same component).  Which approach you use for a given data item is largely a matter of personal choice, although there are some factors to consider:&lt;br /&gt;
* Core code included in the Joomla! installation makes it very easy to produce the appropriate form elements for entering data into &#039;&#039;&#039;parameters&#039;&#039;&#039; in the Back-end.  If you choose to save the data in separate fields, you will need to code the appropriate form elements yourself.&lt;br /&gt;
* Again, Joomla! core code allows you to set default values for &#039;&#039;&#039;parameters&#039;&#039;&#039; across the whole component.  Individual component items (e.g. individual articles) can then choose to use the default values, or to override them with values specific to that item.  See below for details of how to do this.&lt;br /&gt;
* It is not possible to extract individual parameter values directly from the database.  Instead, the whole parameters field must be extracted and parsed to obtain the different parameter values.  This means that it is not very easy, for example, to run MySQL queries that search for a parameter with a particular value.  Any data that you want to run queries against should be given its &#039;&#039;&#039;own table field&#039;&#039;&#039;.&lt;br /&gt;
* Similarly, it is not possible to run data validation on parameter fields before saving data.&lt;br /&gt;
In general, parameters are conventionally used to store data relating to the &#039;&#039;presentation&#039;&#039; of information.  The information itself is generally stored in separate fields.&lt;br /&gt;
&lt;br /&gt;
==Types of Component parameter==&lt;br /&gt;
&lt;br /&gt;
===1. Component-wide default parameters===&lt;br /&gt;
&lt;br /&gt;
These parameters are set once for the whole Component, and are generally used to provide the &#039;default&#039; parameter settings for the Component on that particular site.  &lt;br /&gt;
&lt;br /&gt;
===2. Menu item specific parameters===&lt;br /&gt;
&lt;br /&gt;
A menu link to an individual Component item (e.g. an article) can also have parameters associated with it, which can affect the way the Component item is displayed &#039;&#039;using that link&#039;&#039;.  The types of parameters available will depend on the way that the Component item is displayed (the &#039;view&#039; in MVC terms, but don&#039;t worry if this doesn&#039;t mean anything to you!).  However, the precise values of those parameters can be set for each menu link individually.  If there is another menu link to that same Component item, then it is important to realise each menu link may have different parameter values, and so the same article may be displayed differently in the two cases.&lt;br /&gt;
&lt;br /&gt;
A menu link can also override the Component-wide default parameters, so that the override values (if set) are used in place of the default values &#039;&#039;for that Component item when accessed via that menu link&#039;&#039;.  As you would expect, when no override value is set, the default value is used instead, in the normal manner.&lt;br /&gt;
&lt;br /&gt;
===3. &#039;Article&#039; specific parameters===&lt;br /&gt;
&lt;br /&gt;
Finally, each Component item (e.g. article) can have parameters which apply to that item, regardless of how it is accessed (i.e. via any available menu link, or even without reference to a menu at all!).  If the Component designer wants, the article specific parameters can also be set up to use the &#039;override&#039; behaviour, so that they default to the current values of the corresponding Component-wide parameters, though this is not essential.  Again, this is described further below.&lt;br /&gt;
&lt;br /&gt;
==Storing the parameters and their values.==&lt;br /&gt;
&lt;br /&gt;
In general, a set of parameters is stored within the database in a single &amp;lt;code&amp;gt;text&amp;lt;/code&amp;gt; field.  Different parameters are separated by &amp;lt;code&amp;gt;newline&amp;lt;/code&amp;gt; characters (&#039;&amp;lt;code&amp;gt;\n&amp;lt;/code&amp;gt;&#039; in MySQL - each parameter will appear on a different line when you look at the data in something like phpMyAdmin).  Each parameter consists of the parameter name and value, separated by an equals sign (=).  As an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
parameter1=parameter1value&lt;br /&gt;
parameter2=&lt;br /&gt;
parameter3=parameter3value&lt;br /&gt;
parameter4=parameter4value&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, parameter1, parameter3, and parameter4 have all been assigned values, whilst parameter2 has no value.  Typically, a parameter will be given no value where it is set up to allow override of a default value, but &#039;no override is required&#039; - i.e. it is desired to use the default value.&lt;br /&gt;
&lt;br /&gt;
===1. Component-wide default parameters===&lt;br /&gt;
&lt;br /&gt;
These are stored in the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt; field of the jos_components table, in the row corresponding to the particular component to which they apply.&lt;br /&gt;
&lt;br /&gt;
===2. Menu item specific parameters===&lt;br /&gt;
&lt;br /&gt;
These are stored in the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt; field of the jos_menu table, in the row corresponding to the particular menu item to which they apply.&lt;br /&gt;
&lt;br /&gt;
===3. &#039;Article&#039; specific parameters===&lt;br /&gt;
&lt;br /&gt;
These are stored in a text field in the table created by the Component.  Whilst there is no strict rule for naming the field, it is common to extend the above pattern using the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt; name.  However, com_content stores article parameters in a field called &amp;lt;code&amp;gt;attribs&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Accessing the parameters - Back-end==&lt;br /&gt;
&lt;br /&gt;
Joomla! includes some shortcuts to enable component creators to easily add parameter forms to the Back-end of their component.  These forms allow a site administrator to enter a parameter value by, for example, entering some text in a box, choosing from a drop-down list, or selecting a radio button.  To create these forms, each parameter needs to have an associated &amp;lt;code&amp;gt;&amp;lt;param /&amp;gt;&amp;lt;/code&amp;gt; object in an XML file.  The type of &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;param /&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; object determines the form elements that will be shown in the Back-end.  A list of the available form elements is given [[Standard_parameter_types|here]].  More information is given below about the XML file names, structure and location required for each set of parameters.&lt;br /&gt;
&lt;br /&gt;
===1. Component-wide default parameters===&lt;br /&gt;
&lt;br /&gt;
These can be created at installation of the Component, by including &amp;lt;code&amp;gt;&amp;lt;param /&amp;gt;&amp;lt;/code&amp;gt; elements in the installation XML file (typically called COMPONENT_NAME.xml, and located in the root folder of the Component package.  As far as the parameters are concerned, this XML file has the following structure:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;install&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
  &amp;lt;params&amp;gt;&lt;br /&gt;
    &amp;lt;param /&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;!-- Example: the following will create a line in the parameters field &lt;br /&gt;
    reading &#039;font_size=16\n&#039;: --&amp;gt;&lt;br /&gt;
    &amp;lt;param name=&amp;quot;font_size&amp;quot; default=&amp;quot;16&amp;quot; /&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    ...&lt;br /&gt;
  &amp;lt;/params&amp;gt;&lt;br /&gt;
  &amp;lt;url addpath=&amp;quot;....&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;param /&amp;gt;&lt;br /&gt;
  &amp;lt;/url&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/install&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Each &amp;lt;code&amp;gt;&amp;lt;param /&amp;gt;&amp;lt;/code&amp;gt; element must be given the attributes &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;, which define the parameter name and value respectively.  These values are then copied to the jos_components table in the database.&lt;br /&gt;
&lt;br /&gt;
However, on its own this is not very useful, as it doesn&#039;t allow users to change the values of the parameters.  To do this, parameter form elements need to be defined in a file named &amp;lt;code&amp;gt;config.xml&amp;lt;/code&amp;gt; which is located in &amp;lt;code&amp;gt;/PATH_TO_JOOMLA/administrator/components/com_COMPONENT_NAME/&amp;lt;/code&amp;gt;.  The file should have the following structure:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;root&amp;gt;&lt;br /&gt;
  &amp;lt;params&amp;gt;&lt;br /&gt;
    &amp;lt;url addpath=&amp;quot;/administrator/components/com_COMPONENT_NAME/elements&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;param name=&amp;quot;cid&amp;quot; type=&amp;quot;JELEMENT_TYPE_NAME&amp;quot; scope=&amp;quot;com_COMPONENT_NAME&amp;quot; default=&amp;quot;0&amp;quot; label=&amp;quot;LABEL&amp;quot; description=&amp;quot;DESCRIPTION&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/url&amp;gt;&lt;br /&gt;
    &amp;lt;param type=&amp;quot;type&amp;quot; name=&amp;quot;name&amp;quot; description=&amp;quot;description&amp;quot; /&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;!-- Example: the following will produce a text box 3 characters wide with the label &#039;Font size:&#039;.  &lt;br /&gt;
    When the user hovers the mouse over the label, a tooltip will pop up which states &#039;Please enter the &lt;br /&gt;
    required font size&#039;.  On saving, a value entered into the text box will be saved as the &#039;font_size&#039; &lt;br /&gt;
    parameter value. --&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;param type=&amp;quot;text&amp;quot; name=&amp;quot;font_size&amp;quot; size=&amp;quot;3&amp;quot; label=&amp;quot;Font size:&amp;quot; description=&amp;quot;Please enter the required font size&amp;quot; /&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    ...&lt;br /&gt;
  &amp;lt;/params&amp;gt;&lt;br /&gt;
&amp;lt;/root&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note that the &amp;lt;code&amp;gt;&amp;lt;root&amp;gt;&amp;lt;/code&amp;gt; element can have any name you wish, but there must be one element at the root of the document (this is a requirement for a well-formed XML document). You can have more than one &amp;lt;code&amp;gt;&amp;lt;params&amp;gt;&amp;lt;/code&amp;gt; element, but only the first one will be considered.  It is not currently possible to group certain parameter form elements together.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;lt;url&amp;gt;&amp;lt;/code&amp;gt; section contains parameters which are added to the URL of the menu item. To enable this functionality, the &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt; attribute of the &amp;lt;code&amp;gt;&amp;lt;param&amp;gt;&amp;lt;/code&amp;gt; elements must specify the name of a class which extends JElement, and is able to generate HTML forms to display and set the parameter. You can use one of the [[Standard parameter types]]. Or, you can create your own subclass of JElement. Put the class definition file in your component&#039;s &amp;lt;code&amp;gt;/administrator/components/com_COMPONENT_NAME/&amp;lt;/code&amp;gt; directory, and refer to this path in the &amp;lt;code&amp;gt;addpath&amp;lt;/code&amp;gt; attribute of the &amp;lt;code&amp;gt;&amp;lt;URL&amp;gt;&amp;lt;/code&amp;gt; element. More information here: http://forum.joomla.org/viewtopic.php?f=476&amp;amp;t=206062.&lt;br /&gt;
&lt;br /&gt;
So that administrators to access these parameters, you will need to add a button to the toolbar in the Back-end of your component.  This can be done using the code:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JToolBarHelper::preferences( &#039;com_COMPONENT_NAME&#039; );&lt;br /&gt;
// e.g. for the core Content component, you would use JToolBarHelper::preferences( &#039;com_content&#039; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
which is typically placed in the PHP file responsible for the Back-end output.  (For example, using an MVC structure, you might place this code at the top of &amp;lt;code&amp;gt;/PATH_TO_JOOMLA/administrator/components/com_COMPONENT_NAME/views/VIEW_NAME/tmpl/default.php&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This adds a &amp;lt;code&amp;gt;Parameters&amp;lt;/code&amp;gt; button to the toolbar:&lt;br /&gt;
&lt;br /&gt;
[[Image:Toolbar_newsfeed.png]]&lt;br /&gt;
&lt;br /&gt;
Clicking on the toolbar button produces a pop-up window containing the form fields for each parameter defined in &amp;lt;code&amp;gt;config.xml&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that there is no need to define &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt; attributes for the &amp;lt;code&amp;gt;&amp;lt;param /&amp;gt;&amp;lt;/code&amp;gt; elements in the &amp;lt;code&amp;gt;config.xml&amp;lt;/code&amp;gt; file, since the default values will already have been saved in the installation of the Component.&lt;br /&gt;
&lt;br /&gt;
===2. Menu item specific parameters===&lt;br /&gt;
&lt;br /&gt;
A menu item is associated with a particular view from your Component&#039;s Front-end - following the menu link in the Front-end will display that view.  Joomla! 1.5 allows you to define parameters for a particular view, so that a copy of those parameters can be associated with each menu item using the view.  In addition, you can also choose to override the Component-wide default parameters defined as above, so that the override values will apply to the particular menu item.&lt;br /&gt;
&lt;br /&gt;
The view parameters are defined in an XML file stored in the &#039;&#039;Front-end&#039;&#039; view output template directory.  (This is not to be confused with the site Template directory, which is different!). The XML file has the same name as the layout used with the template. For most applications you will be using the default layout. Thus the path to the XML file is something like: &amp;lt;code&amp;gt;/PATH_TO_JOOMLA/components/com_COMPONENT_NAME/views/VIEW_NAME/tmpl/default.xml&amp;lt;/code&amp;gt;.  The structure of the file is:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;metadata&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
  &amp;lt;state&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;params&amp;gt;&lt;br /&gt;
      &amp;lt;param /&amp;gt;&lt;br /&gt;
      ...&lt;br /&gt;
    &amp;lt;/params&amp;gt;&lt;br /&gt;
    &amp;lt;url&amp;gt;&lt;br /&gt;
      &amp;lt;param /&amp;gt;&lt;br /&gt;
      ...&lt;br /&gt;
    &amp;lt;/url&amp;gt;&lt;br /&gt;
    &amp;lt;advanced&amp;gt;&lt;br /&gt;
      &amp;lt;param /&amp;gt;&lt;br /&gt;
      ...&lt;br /&gt;
    &amp;lt;/advanced&amp;gt;&lt;br /&gt;
  &amp;lt;/state&amp;gt;&lt;br /&gt;
&amp;lt;/metadata&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See [[Standard parameter types]] for a full list of the core parameter types. (You can use these types within a &amp;lt;code&amp;gt;&amp;lt;url&amp;gt;&amp;lt;/code&amp;gt; section without needing to supply an &amp;lt;code&amp;gt;addpath&amp;lt;/code&amp;gt; attribute.)&lt;br /&gt;
&lt;br /&gt;
Displaying the forms for these parameters is handled automatically by the core &amp;lt;code&amp;gt;com_menus&amp;lt;/code&amp;gt; component, which creates a number of slider panes on the right hand side (at least when viewed using the default Khepri backend site Template) of the menu item edit screen.  Any parameters defined within the &amp;lt;code&amp;gt;&amp;lt;params&amp;gt;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&amp;lt;url&amp;gt;&amp;lt;/code&amp;gt; tags will appear in the &amp;lt;code&amp;gt;Parameters - Basic&amp;lt;/code&amp;gt; slider pane.  Any parameters defined within the &amp;lt;code&amp;gt;&amp;lt;advanced&amp;gt;&amp;lt;/code&amp;gt; tag will appear in the &amp;lt;code&amp;gt;Parameters - Advanced&amp;lt;/code&amp;gt; slider pane.&lt;br /&gt;
&lt;br /&gt;
The following screenshot shows the menu admin page for the Category &#039;List&#039; layout.  You can see that the &amp;lt;code&amp;gt;Parameters - Basic&amp;lt;/code&amp;gt; slider pane is open, and contains form elements for five parameters.  There are no &#039;Advanced&#039; parameters for this view, and so the &amp;lt;code&amp;gt;Parameters - Advanced&amp;lt;/code&amp;gt; slider pane is not shown:&lt;br /&gt;
&lt;br /&gt;
[[Image:Menu items edit.png]]&lt;br /&gt;
&lt;br /&gt;
For the override of the Component-wide default parameters, &amp;lt;code&amp;gt;com_menus&amp;lt;/code&amp;gt; uses the same &amp;lt;code&amp;gt;config.xml&amp;lt;/code&amp;gt; file as above, so there is no need to define these parameters again.  The override forms are automatically added to a slider pane named &amp;lt;code&amp;gt;Parameters - Component&amp;lt;/code&amp;gt;.  However, there are a number of changes from the forms used in the Preferences pop-up window (despite being based on the same &amp;lt;code&amp;gt;config.xml&amp;lt;/code&amp;gt; file):&lt;br /&gt;
* Any &amp;lt;code&amp;gt;&amp;lt;param type=&amp;quot;radio&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt; parameter is shown not as a radio button form field, but by a drop-down list.&lt;br /&gt;
* All drop-down lists (both those defined as such in &amp;lt;code&amp;gt;config.xml&amp;lt;/code&amp;gt;, and those defined as radio buttons) are given an extra  option.  This extra option displays the text &amp;quot;Use Global&amp;quot; but has an associated value of an empty string.  The &amp;quot;Use Global&amp;quot; option is set as the default option for the list.  Thus, by default, these parameters will use the Component-wide default values, rather than overriding them.  (However, note that any text box fields defined with a default value in &amp;lt;code&amp;gt;config.xml&amp;lt;/code&amp;gt; retain that default value, and so will override the component-wide default value if that is different).&lt;br /&gt;
&lt;br /&gt;
===3. &#039;Article&#039; specific parameters===&lt;br /&gt;
&lt;br /&gt;
These are defined in an XML file which can be stored anywhere you like, but is typically placed within the &amp;lt;code&amp;gt;models&amp;lt;/code&amp;gt; folder of the Component Back-end (if you are using an MVC structure) and named according to the model to which they apply, i.e. &amp;lt;code&amp;gt;PATH_TO_JOOMLA/administrator/components/com_COMPONENT_NAME/models/MODEL_NAME.xml&amp;lt;/code&amp;gt;.  The XML file has the following structure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;root&amp;gt;&lt;br /&gt;
  &amp;lt;params&amp;gt;&lt;br /&gt;
    &amp;lt;param /&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
  &amp;lt;/params&amp;gt;&lt;br /&gt;
  &amp;lt;params group=&amp;quot;GROUP_NAME&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;param /&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
  &amp;lt;/params&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/root&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above, you can give the &amp;lt;code&amp;gt;&amp;lt;root&amp;gt;&amp;lt;/code&amp;gt; element whatever name you wish.  You can also have as many &amp;lt;code&amp;gt;&amp;lt;params&amp;gt;&amp;lt;/code&amp;gt; groups as you like, though each group must have a &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; attribute with a different &amp;lt;code&amp;gt;GROUP_NAME&amp;lt;/code&amp;gt;.  If there are two or more &amp;lt;code&amp;gt;&amp;lt;params&amp;gt;&amp;lt;/code&amp;gt; groups with the same &amp;lt;code&amp;gt;GROUP_NAME&amp;lt;/code&amp;gt;, only the last one in the list will be considered.&lt;br /&gt;
&lt;br /&gt;
To display the forms for these parameters in the Back-end of your Component, you will need to do a little work yourself.  Firstly, you need to access the saved parameter data from the database.  For this, you will need to identify both the location of the stored parameters data in the database, and the XML file that you are using to define the parameter form fields.  Assuming that you have already created a &amp;lt;code&amp;gt;$row&amp;lt;/code&amp;gt; variable to hold your component item (i.e. &#039;article&#039;) data, that the parameters data is stored in the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt; field of the &amp;lt;code&amp;gt;$row&amp;lt;/code&amp;gt;, and that the XML file is located in the models folder as specified above, you could use the following code:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$paramsdata = $row-&amp;gt;params;&lt;br /&gt;
$paramsdefs = JPATH_COMPONENT.DS.&#039;models&#039;.DS.&#039;MODEL_NAME.xml&#039;;&lt;br /&gt;
$params = new JParameter( $paramsdata, $paramsdefs );&lt;br /&gt;
&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;params&#039;, $params);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This code is typically placed in the View file (e.g. view.html.php) within the corresponding folder.&lt;br /&gt;
&lt;br /&gt;
To display the parameters forms in slider panes (in the same way that they are displayed in the menu item Back-end), you should use the following code in the template file (e.g. &amp;lt;code&amp;gt;PATH_TO_JOOMLA/administrator/com_COMPONENT_NAME/views/VIEW_NAME/tmpl/default.php&amp;lt;/code&amp;gt;):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.html.pane&#039;);&lt;br /&gt;
&lt;br /&gt;
$pane =&amp;amp; JPane::getInstance( &#039;sliders&#039; );&lt;br /&gt;
&lt;br /&gt;
echo $pane-&amp;gt;startPane( &#039;content-pane&#039; );&lt;br /&gt;
&lt;br /&gt;
// First slider panel&lt;br /&gt;
// Create a slider panel with a title of SLIDER_PANEL_1_TITLE and a title id attribute of SLIDER_PANEL_1_NAME&lt;br /&gt;
echo $pane-&amp;gt;startPanel( JText::_( &#039;SLIDER_PANEL_1_TITLE&#039; ), &#039;SLIDER_PANEL_1_NAME&#039; );&lt;br /&gt;
// Display the parameters defined in the &amp;lt;params&amp;gt; group with no &#039;group&#039; attribute&lt;br /&gt;
echo $this-&amp;gt;params-&amp;gt;render( &#039;params&#039; );&lt;br /&gt;
echo $pane-&amp;gt;endPanel();&lt;br /&gt;
&lt;br /&gt;
//Second slider panel&lt;br /&gt;
// Create a slider panel with a title of SLIDER_PANEL_2_TITLE and a title id attribute of SLIDER_PANEL_2_NAME&lt;br /&gt;
echo $pane-&amp;gt;startPanel( JText::_( &#039;SLIDER_PANEL_2_TITLE&#039; ), &#039;SLIDER_PANEL_2_NAME&#039; );&lt;br /&gt;
// Display the parameters defined in the &amp;lt;params&amp;gt; group with the &#039;group&#039; attribute of &#039;GROUP_NAME&#039;&lt;br /&gt;
echo $this-&amp;gt;params-&amp;gt;render( &#039;params&#039;, &#039;GROUP_NAME&#039; );&lt;br /&gt;
echo $pane-&amp;gt;endPanel();&lt;br /&gt;
&lt;br /&gt;
// Repeat for each additional slider panel required&lt;br /&gt;
&lt;br /&gt;
echo $pane-&amp;gt;endPane();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In order to save the parameters to the database you have to overload the bind() function which can be found in &lt;br /&gt;
&amp;lt;code&amp;gt;PATH_TO_JOOMLA/administrator/com_COMPONENT_NAME/tables/COMPONENT_NAME.php&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
function bind($array, $ignore = &#039;&#039;)&lt;br /&gt;
{&lt;br /&gt;
	if (key_exists( &#039;params&#039;, $array ) &amp;amp;&amp;amp; is_array( $array[&#039;params&#039;] ))&lt;br /&gt;
	{&lt;br /&gt;
		$registry = new JRegistry();&lt;br /&gt;
		$registry-&amp;gt;loadArray($array[&#039;params&#039;]);&lt;br /&gt;
		$array[&#039;params&#039;] = $registry-&amp;gt;toString();&lt;br /&gt;
	}&lt;br /&gt;
	return parent::bind($array, $ignore);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Accessing the parameters - frontend==&lt;br /&gt;
&lt;br /&gt;
The Front-end situation is a bit more complex than the Back-end.  The &#039;standard&#039; way to deal with parameters in the Front-end is to set up a cascade of overrides, as described above:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Item-specific &#039;&#039;overrides&#039;&#039; Menu-specific &#039;&#039;overrides&#039;&#039; Component-default&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
If you &#039;&#039;&#039;don&#039;t&#039;&#039;&#039; want to do this, then a little extra work is required&lt;br /&gt;
&lt;br /&gt;
===With overrides===&lt;br /&gt;
&lt;br /&gt;
The following code will access the Component-wide default parameters, &#039;&#039;already overridden&#039;&#039; with those for the menu item (if applicable):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  $params = &amp;amp;JComponentHelper::getParams( &#039;COMPONENT_NAME&#039; );&lt;br /&gt;
&lt;br /&gt;
  // e.g. for the com_weblinks component, you would use:&lt;br /&gt;
  // $params = &amp;amp;JComponentHelper::getParams( &#039;com_weblinks&#039; )&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In an MVC structure, this code would be placed in the &amp;lt;code&amp;gt;view.html.php&amp;lt;/code&amp;gt; file for the particular view required.&lt;br /&gt;
&lt;br /&gt;
Assuming that the item parameters are stored in the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt; field, and that the particular item has been loaded into the &amp;lt;code&amp;gt;$row&amp;lt;/code&amp;gt; object by the method, you would then add in the item parameters to the &amp;lt;code&amp;gt;$params&amp;lt;/code&amp;gt; object using:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  $params-&amp;gt;merge( new JParameter( &amp;amp;$row-&amp;gt;params ) );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that, in both cases (i.e. overrides by menu-specific parameters, and overrides by item-specific parameters), we aren&#039;t &#039;&#039;just&#039;&#039; doing overrides - we also add in any new parameters that weren&#039;t found in the defaults.  In other words, the &amp;lt;code&amp;gt;$params&amp;lt;/code&amp;gt; object ends up with all the parameters we need!&lt;br /&gt;
&lt;br /&gt;
To access the value of a specific parameter, we would use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  $params-&amp;gt;get( &#039;PARAMETER_NAME&#039; );&lt;br /&gt;
&lt;br /&gt;
  // e.g. to obtain the value of &#039;parameter1&#039;, we use:&lt;br /&gt;
  // $params-&amp;gt;get( &#039;parameter1&#039; );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is important to realise that any &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; carried out is persistent, so the following code (where for example you have an array containing the parameters sets for several items, and you want the parameters for each item to individually override the defaults) would not produce the result you might expect:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  foreach ($itemparamsgroup as $itemparams)&lt;br /&gt;
  {&lt;br /&gt;
    $params = &amp;amp;JComponentHelper::getParams( &#039;COMPONENT_NAME&#039; );&lt;br /&gt;
    $params-&amp;gt;merge( $itemparams );&lt;br /&gt;
    echo $params-&amp;gt;get( &#039;PARAMETER_NAME&#039; );&lt;br /&gt;
  }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In such cases, you will need to use the non-override method, and then force the overrides manually, as described below.&lt;br /&gt;
&lt;br /&gt;
===Without overrides===&lt;br /&gt;
&lt;br /&gt;
There will be cases where you don&#039;t want to use the default override pattern. For example, you may want to ignore the menu-specific parameters, and have only the item-specific parameters overriding the defaults. This is a little more difficult to accomplish, although it can still be done.&lt;br /&gt;
&lt;br /&gt;
You can access the Component-wide default parameter values, &#039;&#039;without the menu overrides&#039;&#039;, as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  $component = JComponentHelper::getComponent( &#039;COMPONENT_NAME&#039; );&lt;br /&gt;
  $params = new JParameter( $component-&amp;gt;params );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to override these with the menu parameters, but &#039;&#039;without&#039;&#039; the &#039;persistence&#039; effect described above, you can:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  $menuitemid = JRequest::getInt( &#039;Itemid&#039; );&lt;br /&gt;
  if ($menuitemid)&lt;br /&gt;
  {&lt;br /&gt;
    $menu = JSite::getMenu();&lt;br /&gt;
    $menuparams = $menu-&amp;gt;getParams( $menuitemid );&lt;br /&gt;
    $params-&amp;gt;merge( $menuparams );&lt;br /&gt;
  }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can access the item parameters as before, and choose whether to merge them in using the code above, or simply store them in a separate object:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  $itemparams = new JParameter( $row-&amp;gt;params );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can combine this code to achieve the effect that you want.  For example, you could override the Component-wide defaults with the item-specific parameters, but ignore those for the menu.  Or you could use the menu-specific parameters in some circumstances, and the item-specific ones in others.  [Whenever you depart from the standard approach, though, you should be careful that you inform your users how your Component works.  Users will expect your component to work the same way as those from the Joomla! core, so you should have a good reason for departing from this approach.]&lt;br /&gt;
&lt;br /&gt;
Accessing the value of a particular parameter is done in the same way as described above.&lt;br /&gt;
&lt;br /&gt;
[[Category:Components]]&lt;br /&gt;
[[Category:Parameters]]&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Component Management]]&lt;br /&gt;
[[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J1.5:Component_parameters&amp;diff=36731</id>
		<title>J1.5:Component parameters</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J1.5:Component_parameters&amp;diff=36731"/>
		<updated>2011-02-03T22:55:35Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: /* 2. Menu item specific parameters */ Corrected misspelling.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background==&lt;br /&gt;
One thing that sets Joomla! Components apart from other types of Extension (i.e. Modules and Plugins) is the ability to store significant quantities of data in the Joomla! MySQL database.  Typically, this data will be content for displaying on a page (such as the content of an article, or its title) or data about how that content should be displayed (e.g. a setting specifying whether or not the title should be shown).  A Component normally creates at least one table in the database to store this data - for example, data for articles associated with the &amp;lt;code&amp;gt;com_content&amp;lt;/code&amp;gt; Component are stored in the &amp;lt;code&amp;gt;jos_content&amp;lt;/code&amp;gt; table (where &#039;&#039;jos&#039;&#039; is the table prefix for the site).&lt;br /&gt;
&lt;br /&gt;
However, choosing exactly how to store each item of data requires a little more thought.  There are essentially two choices:  each data item may be stored in its own field, or a collection of data items may be stored within a single parameters field.  (Of course, there is nothing to stop you making use of both methods, for different data items, within the same component).  Which approach you use for a given data item is largely a matter of personal choice, although there are some factors to consider:&lt;br /&gt;
* Core code included in the Joomla! installation makes it very easy to produce the appropriate form elements for entering data into &#039;&#039;&#039;parameters&#039;&#039;&#039; in the Back-end.  If you choose to save the data in separate fields, you will need to code the appropriate form elements yourself.&lt;br /&gt;
* Again, Joomla! core code allows you to set default values for &#039;&#039;&#039;parameters&#039;&#039;&#039; across the whole component.  Individual component items (e.g. individual articles) can then choose to use the default values, or to override them with values specific to that item.  See below for details of how to do this.&lt;br /&gt;
* It is not possible to extract individual parameter values directly from the database.  Instead, the whole parameters field must be extracted and parsed to obtain the different parameter values.  This means that it is not very easy, for example, to run MySQL queries that search for a parameter with a particular value.  Any data that you want to run queries against should be given its &#039;&#039;&#039;own table field&#039;&#039;&#039;.&lt;br /&gt;
* Similarly, it is not possible to run data validation on parameter fields before saving data.&lt;br /&gt;
In general, parameters are conventionally used to store data relating to the &#039;&#039;presentation&#039;&#039; of information.  The information itself is generally stored in separate fields.&lt;br /&gt;
&lt;br /&gt;
==Types of Component parameter==&lt;br /&gt;
&lt;br /&gt;
===1. Component-wide default parameters===&lt;br /&gt;
&lt;br /&gt;
These parameters are set once for the whole Component, and are generally used to provide the &#039;default&#039; parameter settings for the Component on that particular site.  &lt;br /&gt;
&lt;br /&gt;
===2. Menu item specific parameters===&lt;br /&gt;
&lt;br /&gt;
A menu link to an individual Component item (e.g. an article) can also have parameters associated with it, which can affect the way the Component item is displayed &#039;&#039;using that link&#039;&#039;.  The types of parameters available will depend on the way that the Component item is displayed (the &#039;view&#039; in MVC terms, but don&#039;t worry if this doesn&#039;t mean anything to you!).  However, the precise values of those parameters can be set for each menu link individually.  If there is another menu link to that same Component item, then it is important to realise each menu link may have different parameter values, and so the same article may be displayed differently in the two cases.&lt;br /&gt;
&lt;br /&gt;
A menu link can also override the Component-wide default parameters, so that the override values (if set) are used in place of the default values &#039;&#039;for that Component item when accessed via that menu link&#039;&#039;.  As you would expect, when no override value is set, the default value is used instead, in the normal manner.&lt;br /&gt;
&lt;br /&gt;
===3. &#039;Article&#039; specific parameters===&lt;br /&gt;
&lt;br /&gt;
Finally, each Component item (e.g. article) can have parameters which apply to that item, regardless of how it is accessed (i.e. via any available menu link, or even without reference to a menu at all!).  If the Component designer wants, the article specific parameters can also be set up to use the &#039;override&#039; behaviour, so that they default to the current values of the corresponding Component-wide parameters, though this is not essential.  Again, this is described further below.&lt;br /&gt;
&lt;br /&gt;
==Storing the parameters and their values.==&lt;br /&gt;
&lt;br /&gt;
In general, a set of parameters is stored within the database in a single &amp;lt;code&amp;gt;text&amp;lt;/code&amp;gt; field.  Different parameters are separated by &amp;lt;code&amp;gt;newline&amp;lt;/code&amp;gt; characters (&#039;&amp;lt;code&amp;gt;\n&amp;lt;/code&amp;gt;&#039; in MySQL - each parameter will appear on a different line when you look at the data in something like phpMyAdmin).  Each parameter consists of the parameter name and value, separated by an equals sign (=).  As an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
parameter1=parameter1value&lt;br /&gt;
parameter2=&lt;br /&gt;
parameter3=parameter3value&lt;br /&gt;
parameter4=parameter4value&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, parameter1, parameter3, and parameter4 have all been assigned values, whilst parameter2 has no value.  Typically, a parameter will be given no value where it is set up to allow override of a default value, but &#039;no override is required&#039; - i.e. it is desired to use the default value.&lt;br /&gt;
&lt;br /&gt;
===1. Component-wide default parameters===&lt;br /&gt;
&lt;br /&gt;
These are stored in the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt; field of the jos_components table, in the row corresponding to the particular component to which they apply.&lt;br /&gt;
&lt;br /&gt;
===2. Menu item specific parameters===&lt;br /&gt;
&lt;br /&gt;
These are stored in the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt; field of the jos_menu table, in the row corresponding to the particular menu item to which they apply.&lt;br /&gt;
&lt;br /&gt;
===3. &#039;Article&#039; specific parameters===&lt;br /&gt;
&lt;br /&gt;
These are stored in a text field in the table created by the Component.  Whilst there is no strict rule for naming the field, it is common to extend the above pattern using the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt; name.  However, com_content stores article parameters in a field called &amp;lt;code&amp;gt;attribs&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Accessing the parameters - Back-end==&lt;br /&gt;
&lt;br /&gt;
Joomla! includes some shortcuts to enable component creators to easily add parameter forms to the Back-end of their component.  These forms allow a site administrator to enter a parameter value by, for example, entering some text in a box, choosing from a drop-down list, or selecting a radio button.  To create these forms, each parameter needs to have an associated &amp;lt;code&amp;gt;&amp;lt;param /&amp;gt;&amp;lt;/code&amp;gt; object in an XML file.  The type of &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;param /&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; object determines the form elements that will be shown in the Back-end.  A list of the available form elements is given [[Standard_parameter_types|here]].  More information is given below about the XML file names, structure and location required for each set of parameters.&lt;br /&gt;
&lt;br /&gt;
===1. Component-wide default parameters===&lt;br /&gt;
&lt;br /&gt;
These can be created at installation of the Component, by including &amp;lt;code&amp;gt;&amp;lt;param /&amp;gt;&amp;lt;/code&amp;gt; elements in the installation XML file (typically called COMPONENT_NAME.xml, and located in the root folder of the Component package.  As far as the parameters are concerned, this XML file has the following structure:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;install&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
  &amp;lt;params&amp;gt;&lt;br /&gt;
    &amp;lt;param /&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;!-- Example: the following will create a line in the parameters field &lt;br /&gt;
    reading &#039;font_size=16\n&#039;: --&amp;gt;&lt;br /&gt;
    &amp;lt;param name=&amp;quot;font_size&amp;quot; default=&amp;quot;16&amp;quot; /&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    ...&lt;br /&gt;
  &amp;lt;/params&amp;gt;&lt;br /&gt;
  &amp;lt;url addpath=&amp;quot;....&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;param /&amp;gt;&lt;br /&gt;
  &amp;lt;/url&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/install&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Each &amp;lt;code&amp;gt;&amp;lt;param /&amp;gt;&amp;lt;/code&amp;gt; element must be given the attributes &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;, which define the parameter name and value respectively.  These values are then copied to the jos_components table in the database.&lt;br /&gt;
&lt;br /&gt;
However, on its own this is not very useful, as it doesn&#039;t allow users to change the values of the parameters.  To do this, parameter form elements need to be defined in a file named &amp;lt;code&amp;gt;config.xml&amp;lt;/code&amp;gt; which is located in &amp;lt;code&amp;gt;/PATH_TO_JOOMLA/administrator/components/com_COMPONENT_NAME/&amp;lt;/code&amp;gt;.  The file should have the following structure:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;root&amp;gt;&lt;br /&gt;
  &amp;lt;params&amp;gt;&lt;br /&gt;
    &amp;lt;url addpath=&amp;quot;/administrator/components/com_COMPONENT_NAME/elements&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;param name=&amp;quot;cid&amp;quot; type=&amp;quot;JELEMENT_TYPE_NAME&amp;quot; scope=&amp;quot;com_COMPONENT_NAME&amp;quot; default=&amp;quot;0&amp;quot; label=&amp;quot;LABEL&amp;quot; description=&amp;quot;DESCRIPTION&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/url&amp;gt;&lt;br /&gt;
    &amp;lt;param type=&amp;quot;type&amp;quot; name=&amp;quot;name&amp;quot; description=&amp;quot;description&amp;quot; /&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;!-- Example: the following will produce a text box 3 characters wide with the label &#039;Font size:&#039;.  &lt;br /&gt;
    When the user hovers the mouse over the label, a tooltip will pop up which states &#039;Please enter the &lt;br /&gt;
    required font size&#039;.  On saving, a value entered into the text box will be saved as the &#039;font_size&#039; &lt;br /&gt;
    parameter value. --&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;param type=&amp;quot;text&amp;quot; name=&amp;quot;font_size&amp;quot; size=&amp;quot;3&amp;quot; label=&amp;quot;Font size:&amp;quot; description=&amp;quot;Please enter the required font size&amp;quot; /&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    ...&lt;br /&gt;
  &amp;lt;/params&amp;gt;&lt;br /&gt;
&amp;lt;/root&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Note that the &amp;lt;code&amp;gt;&amp;lt;root&amp;gt;&amp;lt;/code&amp;gt; element can have any name you wish, but there must be one element at the root of the document (this is a requirement for a well-formed XML document). You can have more than one &amp;lt;code&amp;gt;&amp;lt;params&amp;gt;&amp;lt;/code&amp;gt; element, but only the first one will be considered.  It is not currently possible to group certain parameter form elements together.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;&amp;lt;url&amp;gt;&amp;lt;/code&amp;gt; section contains parameters which are added to the URL of the menu item. To enable this functionality, the &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt; attribute of the &amp;lt;code&amp;gt;&amp;lt;param&amp;gt;&amp;lt;/code&amp;gt; elements must specify the name of a class which extends JElement, and is able to generate HTML forms to display and set the parameter. You can use one of the [[Standard parameter types]]. Or, you can create your own subclass of JElement. Put the class definition file in your component&#039;s &amp;lt;code&amp;gt;/administrator/components/com_COMPONENT_NAME/&amp;lt;/code&amp;gt; directory, and refer to this path in the &amp;lt;code&amp;gt;addpath&amp;lt;/code&amp;gt; attribute of the &amp;lt;code&amp;gt;&amp;lt;URL&amp;gt;&amp;lt;/code&amp;gt; element. More information here: http://forum.joomla.org/viewtopic.php?f=476&amp;amp;t=206062.&lt;br /&gt;
&lt;br /&gt;
So that administrators to access these parameters, you will need to add a button to the toolbar in the Back-end of your component.  This can be done using the code:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JToolBarHelper::preferences( &#039;com_COMPONENT_NAME&#039; );&lt;br /&gt;
// e.g. for the core Content component, you would use JToolBarHelper::preferences( &#039;com_content&#039; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
which is typically placed in the PHP file responsible for the Back-end output.  (For example, using an MVC structure, you might place this code at the top of &amp;lt;code&amp;gt;/PATH_TO_JOOMLA/administrator/components/com_COMPONENT_NAME/views/VIEW_NAME/tmpl/default.php&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This adds a &amp;lt;code&amp;gt;Parameters&amp;lt;/code&amp;gt; button to the toolbar:&lt;br /&gt;
&lt;br /&gt;
[[Image:Toolbar_newsfeed.png]]&lt;br /&gt;
&lt;br /&gt;
Clicking on the toolbar button produces a pop-up window containing the form fields for each parameter defined in &amp;lt;code&amp;gt;config.xml&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that there is no need to define &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt; attributes for the &amp;lt;code&amp;gt;&amp;lt;param /&amp;gt;&amp;lt;/code&amp;gt; elements in the &amp;lt;code&amp;gt;config.xml&amp;lt;/code&amp;gt; file, since the default values will already have been saved in the installation of the Component.&lt;br /&gt;
&lt;br /&gt;
===2. Menu item specific parameters===&lt;br /&gt;
&lt;br /&gt;
A menu item is associated with a particular view from your Component&#039;s Front-end - following the menu link in the Front-end will display that view.  Joomla! 1.5 allows you to define parameters for a particular view, so that a copy of those parameters can be associated with each menu item using the view.  In addition, you can also choose to override the Component-wide default parameters defined as above, so that the override values will apply to the particular menu item.&lt;br /&gt;
&lt;br /&gt;
The view parameters are defined in an XML file stored in the &#039;&#039;Front-end&#039;&#039; view output template directory.  (This is not to be confused with the site Template directory, which is different!). The XML file has the same name as the layout used with the template. For most applications you will be using the default layout. Thus the path the XML file is something like: &amp;lt;code&amp;gt;/PATH_TO_JOOMLA/components/com_COMPONENT_NAME/views/VIEW_NAME/tmpl/default.xml&amp;lt;/code&amp;gt;.  The structure of the file is:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;metadata&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
  &amp;lt;state&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;params&amp;gt;&lt;br /&gt;
      &amp;lt;param /&amp;gt;&lt;br /&gt;
      ...&lt;br /&gt;
    &amp;lt;/params&amp;gt;&lt;br /&gt;
    &amp;lt;url&amp;gt;&lt;br /&gt;
      &amp;lt;param /&amp;gt;&lt;br /&gt;
      ...&lt;br /&gt;
    &amp;lt;/url&amp;gt;&lt;br /&gt;
    &amp;lt;advanced&amp;gt;&lt;br /&gt;
      &amp;lt;param /&amp;gt;&lt;br /&gt;
      ...&lt;br /&gt;
    &amp;lt;/advanced&amp;gt;&lt;br /&gt;
  &amp;lt;/state&amp;gt;&lt;br /&gt;
&amp;lt;/metadata&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See [[Standard parameter types]] for a full list of the core parameter types. (You can use these types within a &amp;lt;code&amp;gt;&amp;lt;url&amp;gt;&amp;lt;/code&amp;gt; section without needing to supply an &amp;lt;code&amp;gt;addpath&amp;lt;/code&amp;gt; attribute.)&lt;br /&gt;
&lt;br /&gt;
Displaying the forms for these parameters is handled automatically by the core &amp;lt;code&amp;gt;com_menus&amp;lt;/code&amp;gt; component, which creates a number of slider panes on the right hand side (at least when viewed using the default Khepri backend site Template) of the menu item edit screen.  Any parameters defined within the &amp;lt;code&amp;gt;&amp;lt;params&amp;gt;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&amp;lt;url&amp;gt;&amp;lt;/code&amp;gt; tags will appear in the &amp;lt;code&amp;gt;Parameters - Basic&amp;lt;/code&amp;gt; slider pane.  Any parameters defined within the &amp;lt;code&amp;gt;&amp;lt;advanced&amp;gt;&amp;lt;/code&amp;gt; tag will appear in the &amp;lt;code&amp;gt;Parameters - Advanced&amp;lt;/code&amp;gt; slider pane.&lt;br /&gt;
&lt;br /&gt;
The following screenshot shows the menu admin page for the Category &#039;List&#039; layout.  You can see that the &amp;lt;code&amp;gt;Parameters - Basic&amp;lt;/code&amp;gt; slider pane is open, and contains form elements for five parameters.  There are no &#039;Advanced&#039; parameters for this view, and so the &amp;lt;code&amp;gt;Parameters - Advanced&amp;lt;/code&amp;gt; slider pane is not shown:&lt;br /&gt;
&lt;br /&gt;
[[Image:Menu items edit.png]]&lt;br /&gt;
&lt;br /&gt;
For the override of the Component-wide default parameters, &amp;lt;code&amp;gt;com_menus&amp;lt;/code&amp;gt; uses the same &amp;lt;code&amp;gt;config.xml&amp;lt;/code&amp;gt; file as above, so there is no need to define these parameters again.  The override forms are automatically added to a slider pane named &amp;lt;code&amp;gt;Parameters - Component&amp;lt;/code&amp;gt;.  However, there are a number of changes from the forms used in the Preferences pop-up window (despite being based on the same &amp;lt;code&amp;gt;config.xml&amp;lt;/code&amp;gt; file):&lt;br /&gt;
* Any &amp;lt;code&amp;gt;&amp;lt;param type=&amp;quot;radio&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt; parameter is shown not as a radio button form field, but by a drop-down list.&lt;br /&gt;
* All drop-down lists (both those defined as such in &amp;lt;code&amp;gt;config.xml&amp;lt;/code&amp;gt;, and those defined as radio buttons) are given an extra  option.  This extra option displays the text &amp;quot;Use Global&amp;quot; but has an associated value of an empty string.  The &amp;quot;Use Global&amp;quot; option is set as the default option for the list.  Thus, by default, these parameters will use the Component-wide default values, rather than overriding them.  (However, note that any text box fields defined with a default value in &amp;lt;code&amp;gt;config.xml&amp;lt;/code&amp;gt; retain that default value, and so will override the component-wide default value if that is different).&lt;br /&gt;
&lt;br /&gt;
===3. &#039;Article&#039; specific parameters===&lt;br /&gt;
&lt;br /&gt;
These are defined in an XML file which can be stored anywhere you like, but is typically placed within the &amp;lt;code&amp;gt;models&amp;lt;/code&amp;gt; folder of the Component Back-end (if you are using an MVC structure) and named according to the model to which they apply, i.e. &amp;lt;code&amp;gt;PATH_TO_JOOMLA/administrator/components/com_COMPONENT_NAME/models/MODEL_NAME.xml&amp;lt;/code&amp;gt;.  The XML file has the following structure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;root&amp;gt;&lt;br /&gt;
  &amp;lt;params&amp;gt;&lt;br /&gt;
    &amp;lt;param /&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
  &amp;lt;/params&amp;gt;&lt;br /&gt;
  &amp;lt;params group=&amp;quot;GROUP_NAME&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;param /&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
  &amp;lt;/params&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/root&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As above, you can give the &amp;lt;code&amp;gt;&amp;lt;root&amp;gt;&amp;lt;/code&amp;gt; element whatever name you wish.  You can also have as many &amp;lt;code&amp;gt;&amp;lt;params&amp;gt;&amp;lt;/code&amp;gt; groups as you like, though each group must have a &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; attribute with a different &amp;lt;code&amp;gt;GROUP_NAME&amp;lt;/code&amp;gt;.  If there are two or more &amp;lt;code&amp;gt;&amp;lt;params&amp;gt;&amp;lt;/code&amp;gt; groups with the same &amp;lt;code&amp;gt;GROUP_NAME&amp;lt;/code&amp;gt;, only the last one in the list will be considered.&lt;br /&gt;
&lt;br /&gt;
To display the forms for these parameters in the Back-end of your Component, you will need to do a little work yourself.  Firstly, you need to access the saved parameter data from the database.  For this, you will need to identify both the location of the stored parameters data in the database, and the XML file that you are using to define the parameter form fields.  Assuming that you have already created a &amp;lt;code&amp;gt;$row&amp;lt;/code&amp;gt; variable to hold your component item (i.e. &#039;article&#039;) data, that the parameters data is stored in the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt; field of the &amp;lt;code&amp;gt;$row&amp;lt;/code&amp;gt;, and that the XML file is located in the models folder as specified above, you could use the following code:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$paramsdata = $row-&amp;gt;params;&lt;br /&gt;
$paramsdefs = JPATH_COMPONENT.DS.&#039;models&#039;.DS.&#039;MODEL_NAME.xml&#039;;&lt;br /&gt;
$params = new JParameter( $paramsdata, $paramsdefs );&lt;br /&gt;
&lt;br /&gt;
$this-&amp;gt;assignRef(&#039;params&#039;, $params);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This code is typically placed in the View file (e.g. view.html.php) within the corresponding folder.&lt;br /&gt;
&lt;br /&gt;
To display the parameters forms in slider panes (in the same way that they are displayed in the menu item Back-end), you should use the following code in the template file (e.g. &amp;lt;code&amp;gt;PATH_TO_JOOMLA/administrator/com_COMPONENT_NAME/views/VIEW_NAME/tmpl/default.php&amp;lt;/code&amp;gt;):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.html.pane&#039;);&lt;br /&gt;
&lt;br /&gt;
$pane =&amp;amp; JPane::getInstance( &#039;sliders&#039; );&lt;br /&gt;
&lt;br /&gt;
echo $pane-&amp;gt;startPane( &#039;content-pane&#039; );&lt;br /&gt;
&lt;br /&gt;
// First slider panel&lt;br /&gt;
// Create a slider panel with a title of SLIDER_PANEL_1_TITLE and a title id attribute of SLIDER_PANEL_1_NAME&lt;br /&gt;
echo $pane-&amp;gt;startPanel( JText::_( &#039;SLIDER_PANEL_1_TITLE&#039; ), &#039;SLIDER_PANEL_1_NAME&#039; );&lt;br /&gt;
// Display the parameters defined in the &amp;lt;params&amp;gt; group with no &#039;group&#039; attribute&lt;br /&gt;
echo $this-&amp;gt;params-&amp;gt;render( &#039;params&#039; );&lt;br /&gt;
echo $pane-&amp;gt;endPanel();&lt;br /&gt;
&lt;br /&gt;
//Second slider panel&lt;br /&gt;
// Create a slider panel with a title of SLIDER_PANEL_2_TITLE and a title id attribute of SLIDER_PANEL_2_NAME&lt;br /&gt;
echo $pane-&amp;gt;startPanel( JText::_( &#039;SLIDER_PANEL_2_TITLE&#039; ), &#039;SLIDER_PANEL_2_NAME&#039; );&lt;br /&gt;
// Display the parameters defined in the &amp;lt;params&amp;gt; group with the &#039;group&#039; attribute of &#039;GROUP_NAME&#039;&lt;br /&gt;
echo $this-&amp;gt;params-&amp;gt;render( &#039;params&#039;, &#039;GROUP_NAME&#039; );&lt;br /&gt;
echo $pane-&amp;gt;endPanel();&lt;br /&gt;
&lt;br /&gt;
// Repeat for each additional slider panel required&lt;br /&gt;
&lt;br /&gt;
echo $pane-&amp;gt;endPane();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In order to save the parameters to the database you have to overload the bind() function which can be found in &lt;br /&gt;
&amp;lt;code&amp;gt;PATH_TO_JOOMLA/administrator/com_COMPONENT_NAME/tables/COMPONENT_NAME.php&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
function bind($array, $ignore = &#039;&#039;)&lt;br /&gt;
{&lt;br /&gt;
	if (key_exists( &#039;params&#039;, $array ) &amp;amp;&amp;amp; is_array( $array[&#039;params&#039;] ))&lt;br /&gt;
	{&lt;br /&gt;
		$registry = new JRegistry();&lt;br /&gt;
		$registry-&amp;gt;loadArray($array[&#039;params&#039;]);&lt;br /&gt;
		$array[&#039;params&#039;] = $registry-&amp;gt;toString();&lt;br /&gt;
	}&lt;br /&gt;
	return parent::bind($array, $ignore);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Accessing the parameters - frontend==&lt;br /&gt;
&lt;br /&gt;
The Front-end situation is a bit more complex than the Back-end.  The &#039;standard&#039; way to deal with parameters in the Front-end is to set up a cascade of overrides, as described above:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Item-specific &#039;&#039;overrides&#039;&#039; Menu-specific &#039;&#039;overrides&#039;&#039; Component-default&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
If you &#039;&#039;&#039;don&#039;t&#039;&#039;&#039; want to do this, then a little extra work is required&lt;br /&gt;
&lt;br /&gt;
===With overrides===&lt;br /&gt;
&lt;br /&gt;
The following code will access the Component-wide default parameters, &#039;&#039;already overridden&#039;&#039; with those for the menu item (if applicable):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  $params = &amp;amp;JComponentHelper::getParams( &#039;COMPONENT_NAME&#039; );&lt;br /&gt;
&lt;br /&gt;
  // e.g. for the com_weblinks component, you would use:&lt;br /&gt;
  // $params = &amp;amp;JComponentHelper::getParams( &#039;com_weblinks&#039; )&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In an MVC structure, this code would be placed in the &amp;lt;code&amp;gt;view.html.php&amp;lt;/code&amp;gt; file for the particular view required.&lt;br /&gt;
&lt;br /&gt;
Assuming that the item parameters are stored in the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt; field, and that the particular item has been loaded into the &amp;lt;code&amp;gt;$row&amp;lt;/code&amp;gt; object by the method, you would then add in the item parameters to the &amp;lt;code&amp;gt;$params&amp;lt;/code&amp;gt; object using:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  $params-&amp;gt;merge( new JParameter( &amp;amp;$row-&amp;gt;params ) );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that, in both cases (i.e. overrides by menu-specific parameters, and overrides by item-specific parameters), we aren&#039;t &#039;&#039;just&#039;&#039; doing overrides - we also add in any new parameters that weren&#039;t found in the defaults.  In other words, the &amp;lt;code&amp;gt;$params&amp;lt;/code&amp;gt; object ends up with all the parameters we need!&lt;br /&gt;
&lt;br /&gt;
To access the value of a specific parameter, we would use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  $params-&amp;gt;get( &#039;PARAMETER_NAME&#039; );&lt;br /&gt;
&lt;br /&gt;
  // e.g. to obtain the value of &#039;parameter1&#039;, we use:&lt;br /&gt;
  // $params-&amp;gt;get( &#039;parameter1&#039; );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is important to realise that any &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; carried out is persistent, so the following code (where for example you have an array containing the parameters sets for several items, and you want the parameters for each item to individually override the defaults) would not produce the result you might expect:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  foreach ($itemparamsgroup as $itemparams)&lt;br /&gt;
  {&lt;br /&gt;
    $params = &amp;amp;JComponentHelper::getParams( &#039;COMPONENT_NAME&#039; );&lt;br /&gt;
    $params-&amp;gt;merge( $itemparams );&lt;br /&gt;
    echo $params-&amp;gt;get( &#039;PARAMETER_NAME&#039; );&lt;br /&gt;
  }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In such cases, you will need to use the non-override method, and then force the overrides manually, as described below.&lt;br /&gt;
&lt;br /&gt;
===Without overrides===&lt;br /&gt;
&lt;br /&gt;
There will be cases where you don&#039;t want to use the default override pattern. For example, you may want to ignore the menu-specific parameters, and have only the item-specific parameters overriding the defaults. This is a little more difficult to accomplish, although it can still be done.&lt;br /&gt;
&lt;br /&gt;
You can access the Component-wide default parameter values, &#039;&#039;without the menu overrides&#039;&#039;, as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  $component = JComponentHelper::getComponent( &#039;COMPONENT_NAME&#039; );&lt;br /&gt;
  $params = new JParameter( $component-&amp;gt;params );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to override these with the menu parameters, but &#039;&#039;without&#039;&#039; the &#039;persistence&#039; effect described above, you can:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  $menuitemid = JRequest::getInt( &#039;Itemid&#039; );&lt;br /&gt;
  if ($menuitemid)&lt;br /&gt;
  {&lt;br /&gt;
    $menu = JSite::getMenu();&lt;br /&gt;
    $menuparams = $menu-&amp;gt;getParams( $menuitemid );&lt;br /&gt;
    $params-&amp;gt;merge( $menuparams );&lt;br /&gt;
  }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can access the item parameters as before, and choose whether to merge them in using the code above, or simply store them in a separate object:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
  $itemparams = new JParameter( $row-&amp;gt;params );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can combine this code to achieve the effect that you want.  For example, you could override the Component-wide defaults with the item-specific parameters, but ignore those for the menu.  Or you could use the menu-specific parameters in some circumstances, and the item-specific ones in others.  [Whenever you depart from the standard approach, though, you should be careful that you inform your users how your Component works.  Users will expect your component to work the same way as those from the Joomla! core, so you should have a good reason for departing from this approach.]&lt;br /&gt;
&lt;br /&gt;
Accessing the value of a particular parameter is done in the same way as described above.&lt;br /&gt;
&lt;br /&gt;
[[Category:Components]]&lt;br /&gt;
[[Category:Parameters]]&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Component Management]]&lt;br /&gt;
[[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J2.5:File_Structure_and_Naming_Conventions&amp;diff=36728</id>
		<title>J2.5:File Structure and Naming Conventions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J2.5:File_Structure_and_Naming_Conventions&amp;diff=36728"/>
		<updated>2011-02-03T17:14:39Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: /* The /site folder */  edited the view.html.php paragraph to define the .html section as that part of the filename.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
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 Model-View-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 [[Developing a Model-View-Controller Component - Part 1|the MVC tutorial]] for an explanations of the MVC structure.&lt;br /&gt;
&lt;br /&gt;
Joomla!&#039;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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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. &amp;lt;code&amp;gt;CamelCasedController&amp;lt;/code&amp;gt; -&amp;gt; &amp;lt;code&amp;gt;camelcasedcontroller&amp;lt;/code&amp;gt;.&lt;br /&gt;
Similarly, {ViewName} and {viewname}, {ModelName} and {modelname}, {ControllerName} and {controllername}.&lt;br /&gt;
&lt;br /&gt;
== Reserved words ==&lt;br /&gt;
&lt;br /&gt;
There are reserved words which can&#039;t be used in names of classes and components.&lt;br /&gt;
&lt;br /&gt;
An example is the word &amp;quot;view&amp;quot; (in any case) for view classes (except &amp;quot;view&amp;quot; that must be second part of that class name)&amp;lt;ref&amp;gt;Reason is in line 420 of file libraries/joomla/application/component/view.php: &amp;quot;&amp;lt;code&amp;gt;if (!preg_match(&#039;/View((view)*(.*(view)?.*))$/i&#039;, get_class($this), $r)) {&amp;lt;/code&amp;gt;&amp;quot;&amp;lt;/ref&amp;gt;. Because the first part of the name of view classes is the same as the controller class name, controller class names can&#039;t contain the word &amp;quot;view&amp;quot; either. And because of the conventions (although violating of it won&#039;t produce an error), controller class names must contain the component name, so component names can&#039;t contain the word &amp;quot;view&amp;quot; either. So components can&#039;t be named &amp;quot;com_reviews&amp;quot;, or if they are, they must violate the naming conventions and have a different base controller class name (or have some other hacks).&lt;br /&gt;
&lt;br /&gt;
== Installation package vs. actual file placement ==&lt;br /&gt;
&lt;br /&gt;
All Joomla! extensions must be packaged as a .zip installation file. According to the most common file arrangement, the package should contain at least the following two folders as a basic structure:&lt;br /&gt;
* &amp;lt;code&amp;gt;site&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;admin&amp;lt;/code&amp;gt;&lt;br /&gt;
If you set up your XML manifest file according to standard practice, the contents of &amp;lt;code&amp;gt;site&amp;lt;/code&amp;gt; will be installed to &amp;lt;code&amp;gt;/components/com_{componentname}&amp;lt;/code&amp;gt;, whereas the contents of &amp;lt;code&amp;gt;admin&amp;lt;/code&amp;gt; will be installed to &amp;lt;code&amp;gt;/administrator/components/com_{componentname}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== The /site folder==&lt;br /&gt;
This folder keeps the files for the frontend part of the component.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;&amp;lt;code&amp;gt;/site/{componentname}.php&amp;lt;/code&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
:This is the component&#039;s main file and entry point &#039;&#039;for the frontend part&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;&amp;lt;code&amp;gt;/site/controller.php&amp;lt;/code&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
:This file holds the default frontend controller, which is a class called &amp;lt;code&amp;gt;{ComponentName}Controller&amp;lt;/code&amp;gt;. This class must extend the base class &amp;lt;code&amp;gt;JController&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;&amp;lt;code&amp;gt;/site/views&amp;lt;/code&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
:This folder holds the different views for the component.&lt;br /&gt;
&lt;br /&gt;
::&#039;&#039;&#039;&amp;lt;code&amp;gt;/site/views/{viewname}&amp;lt;/code&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
::This folder holds the files for the view {ViewName}.&lt;br /&gt;
&lt;br /&gt;
:::&#039;&#039;&#039;&amp;lt;code&amp;gt;/site/views/{viewname}/view.html.php&amp;lt;/code&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
:::This file is the entry point for the view {ViewName}. It should declare the class &amp;lt;code&amp;gt;{ComponentName}View{ViewName}&amp;lt;/code&amp;gt;. This class must extend the base class &amp;lt;code&amp;gt;JView&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;.html&amp;lt;/code&amp;gt; section of the filename is related to the format the view will be loaded in. For example, if the &amp;lt;code&amp;gt;format&amp;lt;/code&amp;gt; URL parameter is set to &amp;lt;code&amp;gt;format=feed&amp;lt;/code&amp;gt;, the file &amp;lt;code&amp;gt;view.feed.php&amp;lt;/code&amp;gt; will be loaded.&lt;br /&gt;
&lt;br /&gt;
:::&#039;&#039;&#039;&amp;lt;code&amp;gt;/site/views/{viewname}/tmpl&amp;lt;/code&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
:::This folder holds the template files for the view {ViewName}.&lt;br /&gt;
&lt;br /&gt;
::::&#039;&#039;&#039;&amp;lt;code&amp;gt;/site/views/{viewname}/tmpl/default.php&amp;lt;/code&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
::::This is the default template for the view {ViewName}. In this PHP file, the &amp;lt;code&amp;gt;$this&amp;lt;/code&amp;gt; keyword refers to the view class that the template belongs to.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;&amp;lt;code&amp;gt;/site/models&amp;lt;/code&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
:This folder holds additional models, if needed by the application.&lt;br /&gt;
&lt;br /&gt;
::&#039;&#039;&#039;&amp;lt;code&amp;gt;/site/models/{modelname}.php&amp;lt;/code&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
::This file holds the model class &amp;lt;code&amp;gt;{ComponentName}Model{ModelName}&amp;lt;/code&amp;gt;. This class must extend the base class &amp;lt;code&amp;gt;JModel&amp;lt;/code&amp;gt;. Note that the view named {ViewName} will by 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 &#039;&#039;&#039;not&#039;&#039;&#039; a requirement. See [[Using multiple models in an MVC component]] for more information.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;&amp;lt;code&amp;gt;/site/controllers&amp;lt;/code&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
:This folder holds additional controllers, if needed by the application.&lt;br /&gt;
&lt;br /&gt;
::&#039;&#039;&#039;&amp;lt;code&amp;gt;/site/controllers/{controllername}.php&amp;lt;/code&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
::This file holds the controller class &amp;lt;code&amp;gt;{ComponentName}Controller{ControllerName}&amp;lt;/code&amp;gt;. This class must extend the base class &amp;lt;code&amp;gt;JController&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== The /admin folder ==&lt;br /&gt;
The file structure is exactly the same as in the /site folder. Note that the view, models, controllers etc. of the site and admin parts are by default completely separated, and have nothing to do with each other - the site part and the admin part can be thought of as two different components! A view in the /admin folder may have a counterpart with the same name in the /site folder, yet the two views have nothing in common but their name.&lt;br /&gt;
&lt;br /&gt;
However, it might sometimes make sense to share classes between the site and admin parts of the component. Especially models can be shared to avoid duplicating model code. The Joomla! framework supports this strategy. When sharing any code between site and admin applications, the classes should be designed with great care to avoid the possibility of a site user executing admin actions.&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
[[Category:References]][[Category:Component Development]]&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:Developing_a_MVC_Component/Adding_ACL&amp;diff=36667</id>
		<title>Archived:Developing a MVC Component/Adding ACL</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:Developing_a_MVC_Component/Adding_ACL&amp;diff=36667"/>
		<updated>2011-02-02T19:42:50Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: Reworded the &amp;quot;Setting the value in the assets table&amp;quot; paragraph.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial is for {{JVer|1.6}}&lt;br /&gt;
&lt;br /&gt;
== Articles in this series ==&lt;br /&gt;
{{Chunk:Developing a Model-View-Controller (MVC) Component for Joomla!1.6 - Contents}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This tutorial is part of the [[Developing a Model-View-Controller (MVC) Component for Joomla!1.6]] tutorial. You are encouraged to read the previous parts of the tutorial before reading this.&lt;br /&gt;
&lt;br /&gt;
== Describing the ACL ==&lt;br /&gt;
Each component has its own ACL. They can be described in an &#039;&#039;access.xml&#039;&#039; file located at the root of the &#039;&#039;admin&#039;&#039; folder. This file describes the ACL for the com_helloworld component in a different section. In this example, we have chosen to separate the different ACL into two sections: components and messages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/access.xml&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/access.xml&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;access component=&amp;quot;com_helloworld&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;section name=&amp;quot;component&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.admin&amp;quot; title=&amp;quot;JACTION_ADMIN&amp;quot; description=&amp;quot;JACTION_ADMIN_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.manage&amp;quot; title=&amp;quot;JACTION_MANAGE&amp;quot; description=&amp;quot;JACTION_MANAGE_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.create&amp;quot; title=&amp;quot;JACTION_CREATE&amp;quot; description=&amp;quot;JACTION_CREATE_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.delete&amp;quot; title=&amp;quot;JACTION_DELETE&amp;quot; description=&amp;quot;JACTION_DELETE_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.edit&amp;quot; title=&amp;quot;JACTION_EDIT&amp;quot; description=&amp;quot;JACTION_EDIT_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/section&amp;gt;&lt;br /&gt;
	&amp;lt;section name=&amp;quot;message&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.delete&amp;quot; title=&amp;quot;JACTION_DELETE&amp;quot; description=&amp;quot;COM_HELLOWORLD_ACCESS_DELETE_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.edit&amp;quot; title=&amp;quot;JACTION_EDIT&amp;quot; description=&amp;quot;COM_HELLOWORLD_ACCESS_EDIT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/access&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Restricting access to the component ==&lt;br /&gt;
&lt;br /&gt;
The main idea in ACL is to restrict actions to groups of users. The first action to be restricted is access to the component itself. With your favorite file editor, edit the &#039;&#039;admin/helloworld.php&#039;&#039; file and it these lines&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/helloworld.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/helloworld.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// Access check.&lt;br /&gt;
if (!JFactory::getUser()-&amp;gt;authorise(&#039;core.manage&#039;, &#039;com_helloworld&#039;)) &lt;br /&gt;
{&lt;br /&gt;
	return JError::raiseWarning(404, JText::_(&#039;JERROR_ALERTNOAUTHOR&#039;));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// require helper file&lt;br /&gt;
JLoader::register(&#039;HelloWorldHelper&#039;, dirname(__FILE__) . DS . &#039;helpers&#039; . DS . &#039;helloworld.php&#039;);&lt;br /&gt;
&lt;br /&gt;
// import joomla controller library&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
// Get an instance of the controller prefixed by HelloWorld&lt;br /&gt;
$controller = JController::getInstance(&#039;HelloWorld&#039;);&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
 &lt;br /&gt;
// Redirect if set by the controller&lt;br /&gt;
$controller-&amp;gt;redirect();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Displaying only the right toolbar buttons ==&lt;br /&gt;
&lt;br /&gt;
The toolbar buttons that have to displayed depends on the ACL rights.&lt;br /&gt;
&lt;br /&gt;
In the &#039;&#039;admin/views/helloworlds/view.html.php&#039;&#039;, put this code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/views/helloworlds/view.html.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/views/helloworlds/view.html.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// import Joomla view library&lt;br /&gt;
jimport(&#039;joomla.application.component.view&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * HelloWorlds View&lt;br /&gt;
 */&lt;br /&gt;
class HelloWorldViewHelloWorlds extends JView&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * HelloWorlds view display method&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	function display($tpl = null) &lt;br /&gt;
	{&lt;br /&gt;
		// Get data from the model&lt;br /&gt;
		$items = $this-&amp;gt;get(&#039;Items&#039;);&lt;br /&gt;
		$pagination = $this-&amp;gt;get(&#039;Pagination&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Check for errors.&lt;br /&gt;
		if (count($errors = $this-&amp;gt;get(&#039;Errors&#039;))) &lt;br /&gt;
		{&lt;br /&gt;
			JError::raiseError(500, implode(&#039;&amp;lt;br /&amp;gt;&#039;, $errors));&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		// Assign data to the view&lt;br /&gt;
		$this-&amp;gt;items = $items;&lt;br /&gt;
		$this-&amp;gt;pagination = $pagination;&lt;br /&gt;
&lt;br /&gt;
		// Set the toolbar&lt;br /&gt;
		$this-&amp;gt;addToolBar();&lt;br /&gt;
&lt;br /&gt;
		// Display the template&lt;br /&gt;
		parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
		// Set the document&lt;br /&gt;
		$this-&amp;gt;setDocument();&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Setting the toolbar&lt;br /&gt;
	 */&lt;br /&gt;
	protected function addToolBar() &lt;br /&gt;
	{&lt;br /&gt;
		$canDo = HelloWorldHelper::getActions();&lt;br /&gt;
		JToolBarHelper::title(JText::_(&#039;COM_HELLOWORLD_MANAGER_HELLOWORLDS&#039;), &#039;helloworld&#039;);&lt;br /&gt;
		if ($canDo-&amp;gt;get(&#039;core.create&#039;)) &lt;br /&gt;
		{&lt;br /&gt;
			JToolBarHelper::addNew(&#039;helloworld.add&#039;, &#039;JTOOLBAR_NEW&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		if ($canDo-&amp;gt;get(&#039;core.edit&#039;)) &lt;br /&gt;
		{&lt;br /&gt;
			JToolBarHelper::editList(&#039;helloworld.edit&#039;, &#039;JTOOLBAR_EDIT&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		if ($canDo-&amp;gt;get(&#039;core.delete&#039;)) &lt;br /&gt;
		{&lt;br /&gt;
			JToolBarHelper::deleteList(&#039;&#039;, &#039;helloworld.delete&#039;, &#039;JTOOLBAR_DELETE&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		if ($canDo-&amp;gt;get(&#039;core.admin&#039;)) &lt;br /&gt;
		{&lt;br /&gt;
			JToolBarHelper::divider();&lt;br /&gt;
			JToolBarHelper::preferences(&#039;com_helloworld&#039;);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to set up the document properties&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	protected function setDocument() &lt;br /&gt;
	{&lt;br /&gt;
		$document = JFactory::getDocument();&lt;br /&gt;
		$document-&amp;gt;setTitle(JText::_(&#039;COM_HELLOWORLD_ADMINISTRATION&#039;));&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;&#039;admin/views/helloworld/view.html.php&#039;&#039;, put this code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/views/helloworld/view.html.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/views/helloworld/view.html.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// import Joomla view library&lt;br /&gt;
jimport(&#039;joomla.application.component.view&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * HelloWorld View&lt;br /&gt;
 */&lt;br /&gt;
class HelloWorldViewHelloWorld extends JView&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * display method of Hello view&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	public function display($tpl = null) &lt;br /&gt;
	{&lt;br /&gt;
		// get the Data&lt;br /&gt;
		$form = $this-&amp;gt;get(&#039;Form&#039;);&lt;br /&gt;
		$item = $this-&amp;gt;get(&#039;Item&#039;);&lt;br /&gt;
		$script = $this-&amp;gt;get(&#039;Script&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Check for errors.&lt;br /&gt;
		if (count($errors = $this-&amp;gt;get(&#039;Errors&#039;))) &lt;br /&gt;
		{&lt;br /&gt;
			JError::raiseError(500, implode(&#039;&amp;lt;br /&amp;gt;&#039;, $errors));&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		// Assign the Data&lt;br /&gt;
		$this-&amp;gt;form = $form;&lt;br /&gt;
		$this-&amp;gt;item = $item;&lt;br /&gt;
		$this-&amp;gt;script = $script;&lt;br /&gt;
&lt;br /&gt;
		// Set the toolbar&lt;br /&gt;
		$this-&amp;gt;addToolBar();&lt;br /&gt;
&lt;br /&gt;
		// Display the template&lt;br /&gt;
		parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
		// Set the document&lt;br /&gt;
		$this-&amp;gt;setDocument();&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Setting the toolbar&lt;br /&gt;
	 */&lt;br /&gt;
	protected function addToolBar() &lt;br /&gt;
	{&lt;br /&gt;
		JRequest::setVar(&#039;hidemainmenu&#039;, true);&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
		$userId = $user-&amp;gt;id;&lt;br /&gt;
		$isNew = $this-&amp;gt;item-&amp;gt;id == 0;&lt;br /&gt;
		$canDo = HelloWorldHelper::getActions($this-&amp;gt;item-&amp;gt;id);&lt;br /&gt;
		JToolBarHelper::title($isNew ? JText::_(&#039;COM_HELLOWORLD_MANAGER_HELLOWORLD_NEW&#039;) : JText::_(&#039;COM_HELLOWORLD_MANAGER_HELLOWORLD_EDIT&#039;), &#039;helloworld&#039;);&lt;br /&gt;
		// Built the actions for new and existing records.&lt;br /&gt;
		if ($isNew) &lt;br /&gt;
		{&lt;br /&gt;
			// For new records, check the create permission.&lt;br /&gt;
			if ($canDo-&amp;gt;get(&#039;core.create&#039;)) &lt;br /&gt;
			{&lt;br /&gt;
				JToolBarHelper::apply(&#039;helloworld.apply&#039;, &#039;JTOOLBAR_APPLY&#039;);&lt;br /&gt;
				JToolBarHelper::save(&#039;helloworld.save&#039;, &#039;JTOOLBAR_SAVE&#039;);&lt;br /&gt;
				JToolBarHelper::custom(&#039;helloworld.save2new&#039;, &#039;save-new.png&#039;, &#039;save-new_f2.png&#039;, &#039;JTOOLBAR_SAVE_AND_NEW&#039;, false);&lt;br /&gt;
			}&lt;br /&gt;
			JToolBarHelper::cancel(&#039;helloworld.cancel&#039;, &#039;JTOOLBAR_CANCEL&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			if ($canDo-&amp;gt;get(&#039;core.edit&#039;))&lt;br /&gt;
			{&lt;br /&gt;
				// We can save the new record&lt;br /&gt;
				JToolBarHelper::apply(&#039;helloworld.apply&#039;, &#039;JTOOLBAR_APPLY&#039;);&lt;br /&gt;
				JToolBarHelper::save(&#039;helloworld.save&#039;, &#039;JTOOLBAR_SAVE&#039;);&lt;br /&gt;
&lt;br /&gt;
				// We can save this record, but check the create permission to see if we can return to make a new one.&lt;br /&gt;
				if ($canDo-&amp;gt;get(&#039;core.create&#039;)) &lt;br /&gt;
				{&lt;br /&gt;
					JToolBarHelper::custom(&#039;helloworld.save2new&#039;, &#039;save-new.png&#039;, &#039;save-new_f2.png&#039;, &#039;JTOOLBAR_SAVE_AND_NEW&#039;, false);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
			if ($canDo-&amp;gt;get(&#039;core.create&#039;)) &lt;br /&gt;
			{&lt;br /&gt;
				JToolBarHelper::custom(&#039;helloworld.save2copy&#039;, &#039;save-copy.png&#039;, &#039;save-copy_f2.png&#039;, &#039;JTOOLBAR_SAVE_AS_COPY&#039;, false);&lt;br /&gt;
			}&lt;br /&gt;
			JToolBarHelper::cancel(&#039;helloworld.cancel&#039;, &#039;JTOOLBAR_CLOSE&#039;);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to set up the document properties&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	protected function setDocument() &lt;br /&gt;
	{&lt;br /&gt;
		$isNew = $this-&amp;gt;item-&amp;gt;id == 0;&lt;br /&gt;
		$document = JFactory::getDocument();&lt;br /&gt;
		$document-&amp;gt;setTitle($isNew ? JText::_(&#039;COM_HELLOWORLD_HELLOWORLD_CREATING&#039;) : JText::_(&#039;COM_HELLOWORLD_HELLOWORLD_EDITING&#039;));&lt;br /&gt;
		$document-&amp;gt;addScript(JURI::root() . $this-&amp;gt;script);&lt;br /&gt;
		$document-&amp;gt;addScript(JURI::root() . &amp;quot;/administrator/components/com_helloworld/views/helloworld/submitbutton.js&amp;quot;);&lt;br /&gt;
		JText::script(&#039;COM_HELLOWORLD_HELLOWORLD_ERROR_UNACCEPTABLE&#039;);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These two files use the &#039;&#039;getActions&#039;&#039; method defined in the &#039;&#039;admin/helpers/helloworld.php&#039;&#039; file&lt;br /&gt;
&lt;br /&gt;
In the &#039;&#039;admin/helpers/helloworld.php&#039;&#039;, put this code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/helpers/helloworld.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/helpers/helloworld.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * HelloWorld component helper.&lt;br /&gt;
 */&lt;br /&gt;
abstract class HelloWorldHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Configure the Linkbar.&lt;br /&gt;
	 */&lt;br /&gt;
	public static function addSubmenu($submenu) &lt;br /&gt;
	{&lt;br /&gt;
		JSubMenuHelper::addEntry(JText::_(&#039;COM_HELLOWORLD_SUBMENU_MESSAGES&#039;), &#039;index.php?option=com_helloworld&#039;, $submenu == &#039;messages&#039;);&lt;br /&gt;
		JSubMenuHelper::addEntry(JText::_(&#039;COM_HELLOWORLD_SUBMENU_CATEGORIES&#039;), &#039;index.php?option=com_categories&amp;amp;view=categories&amp;amp;extension=com_helloworld&#039;, $submenu == &#039;categories&#039;);&lt;br /&gt;
		// set some global property&lt;br /&gt;
		$document = JFactory::getDocument();&lt;br /&gt;
		$document-&amp;gt;addStyleDeclaration(&#039;.icon-48-helloworld {background-image: url(../media/com_helloworld/images/tux-48x48.png);}&#039;);&lt;br /&gt;
		if ($submenu == &#039;categories&#039;) &lt;br /&gt;
		{&lt;br /&gt;
			$document-&amp;gt;setTitle(JText::_(&#039;COM_HELLOWORLD_ADMINISTRATION_CATEGORIES&#039;));&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get the actions&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getActions($messageId = 0)&lt;br /&gt;
	{&lt;br /&gt;
		$user	= JFactory::getUser();&lt;br /&gt;
		$result	= new JObject;&lt;br /&gt;
&lt;br /&gt;
		if (empty($messageId)) {&lt;br /&gt;
			$assetName = &#039;com_helloworld&#039;;&lt;br /&gt;
		}&lt;br /&gt;
		else {&lt;br /&gt;
			$assetName = &#039;com_helloworld.message.&#039;.(int) $messageId;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$actions = array(&lt;br /&gt;
			&#039;core.admin&#039;, &#039;core.manage&#039;, &#039;core.create&#039;, &#039;core.edit&#039;, &#039;core.delete&#039;&lt;br /&gt;
		);&lt;br /&gt;
&lt;br /&gt;
		foreach ($actions as $action) {&lt;br /&gt;
			$result-&amp;gt;set($action,	$user-&amp;gt;authorise($action, $assetName));&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Adding permissions settings in the component preferences ==&lt;br /&gt;
Since we now use ACL rights in our component, we need to set them at the component level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/config.xml&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/config.xml&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;config&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset&lt;br /&gt;
		name=&amp;quot;greetings&amp;quot;&lt;br /&gt;
		label=&amp;quot;COM_HELLOWORLD_CONFIG_GREETING_SETTINGS_LABEL&amp;quot;&lt;br /&gt;
		description=&amp;quot;COM_HELLOWORLD_CONFIG_GREETING_SETTINGS_DESC&amp;quot;&lt;br /&gt;
	&amp;gt;&lt;br /&gt;
		&amp;lt;field&lt;br /&gt;
			name=&amp;quot;show_category&amp;quot;&lt;br /&gt;
			type=&amp;quot;radio&amp;quot;&lt;br /&gt;
			label=&amp;quot;COM_HELLOWORLD_HELLOWORLD_FIELD_SHOW_CATEGORY_LABEL&amp;quot;&lt;br /&gt;
			description=&amp;quot;COM_HELLOWORLD_HELLOWORLD_FIELD_SHOW_CATEGORY_DESC&amp;quot;&lt;br /&gt;
			default=&amp;quot;0&amp;quot;&lt;br /&gt;
		&amp;gt;&lt;br /&gt;
			&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JHIDE&amp;lt;/option&amp;gt;&lt;br /&gt;
			&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JSHOW&amp;lt;/option&amp;gt;&lt;br /&gt;
		&amp;lt;/field&amp;gt;&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset&lt;br /&gt;
		name=&amp;quot;permissions&amp;quot;&lt;br /&gt;
		label=&amp;quot;JCONFIG_PERMISSIONS_LABEL&amp;quot;&lt;br /&gt;
		description=&amp;quot;JCONFIG_PERMISSIONS_DESC&amp;quot;&lt;br /&gt;
	&amp;gt;&lt;br /&gt;
		&amp;lt;field&lt;br /&gt;
			name=&amp;quot;rules&amp;quot;&lt;br /&gt;
			type=&amp;quot;rules&amp;quot;&lt;br /&gt;
			label=&amp;quot;JCONFIG_PERMISSIONS_LABEL&amp;quot;&lt;br /&gt;
			class=&amp;quot;inputbox&amp;quot;&lt;br /&gt;
			validate=&amp;quot;rules&amp;quot;&lt;br /&gt;
			filter=&amp;quot;rules&amp;quot;&lt;br /&gt;
			component=&amp;quot;com_helloworld&amp;quot;&lt;br /&gt;
			section=&amp;quot;component&amp;quot;&lt;br /&gt;
		/&amp;gt;&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/config&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting the value in the assets table ==&lt;br /&gt;
&lt;br /&gt;
In order to set asset for each message, we have to do two things.&lt;br /&gt;
&lt;br /&gt;
First, the &#039;core.edit&#039; ACL &amp;quot;right&amp;quot; is taken from the message itself, then from the component.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/models/helloworld.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/models/helloworld.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// import Joomla modelform library&lt;br /&gt;
jimport(&#039;joomla.application.component.modeladmin&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * HelloWorld Model&lt;br /&gt;
 */&lt;br /&gt;
class HelloWorldModelHelloWorld extends JModelAdmin&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method override to check if you can edit an existing record.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param	array	$data	An array of input data.&lt;br /&gt;
	 * @param	string	$key	The name of the key for the primary key.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	boolean&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function allowEdit($data = array(), $key = &#039;id&#039;)&lt;br /&gt;
	{&lt;br /&gt;
		// Check specific edit permission then general edit permission.&lt;br /&gt;
		return JFactory::getUser()-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_helloworld.message.&#039;.((int) isset($data[$key]) ? $data[$key] : 0)) or parent::allowEdit($data, $key);&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Returns a reference to the a Table object, always creating it.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param	type	The table type to instantiate&lt;br /&gt;
	 * @param	string	A prefix for the table class name. Optional.&lt;br /&gt;
	 * @param	array	Configuration array for model. Optional.&lt;br /&gt;
	 * @return	JTable	A database object&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	public function getTable($type = &#039;HelloWorld&#039;, $prefix = &#039;HelloWorldTable&#039;, $config = array()) &lt;br /&gt;
	{&lt;br /&gt;
		return JTable::getInstance($type, $prefix, $config);&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to get the record form.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param	array	$data		Data for the form.&lt;br /&gt;
	 * @param	boolean	$loadData	True if the form is to load its own data (default case), false if not.&lt;br /&gt;
	 * @return	mixed	A JForm object on success, false on failure&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	public function getForm($data = array(), $loadData = true) &lt;br /&gt;
	{&lt;br /&gt;
		// Get the form.&lt;br /&gt;
		$form = $this-&amp;gt;loadForm(&#039;com_helloworld.helloworld&#039;, &#039;helloworld&#039;, array(&#039;control&#039; =&amp;gt; &#039;jform&#039;, &#039;load_data&#039; =&amp;gt; $loadData));&lt;br /&gt;
		if (empty($form)) &lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		return $form;&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to get the script that have to be included on the form&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return string	Script files&lt;br /&gt;
	 */&lt;br /&gt;
	public function getScript() &lt;br /&gt;
	{&lt;br /&gt;
		return &#039;administrator/components/com_helloworld/models/forms/helloworld.js&#039;;&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to get the data that should be injected in the form.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	mixed	The data for the form.&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function loadFormData() &lt;br /&gt;
	{&lt;br /&gt;
		// Check the session for previously entered form data.&lt;br /&gt;
		$data = JFactory::getApplication()-&amp;gt;getUserState(&#039;com_helloworld.edit.helloworld.data&#039;, array());&lt;br /&gt;
		if (empty($data)) &lt;br /&gt;
		{&lt;br /&gt;
			$data = $this-&amp;gt;getItem();&lt;br /&gt;
		}&lt;br /&gt;
		return $data;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Second, set the asset name, asset title and asset parent in the helloworld table.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/tables/helloworld.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/tables/helloworld.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// No direct access&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// import Joomla table library&lt;br /&gt;
jimport(&#039;joomla.database.table&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Hello Table class&lt;br /&gt;
 */&lt;br /&gt;
class HelloWorldTableHelloWorld extends JTable&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Constructor&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param object Database connector object&lt;br /&gt;
	 */&lt;br /&gt;
	function __construct(&amp;amp;$db) &lt;br /&gt;
	{&lt;br /&gt;
		parent::__construct(&#039;#__helloworld&#039;, &#039;id&#039;, $db);&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Overloaded bind function&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param       array           named array&lt;br /&gt;
	 * @return      null|string     null is operation was satisfactory, otherwise returns an error&lt;br /&gt;
	 * @see JTable:bind&lt;br /&gt;
	 * @since 1.5&lt;br /&gt;
	 */&lt;br /&gt;
	public function bind($array, $ignore = &#039;&#039;) &lt;br /&gt;
	{&lt;br /&gt;
		if (isset($array[&#039;params&#039;]) &amp;amp;&amp;amp; is_array($array[&#039;params&#039;])) &lt;br /&gt;
		{&lt;br /&gt;
			// Convert the params field to a string.&lt;br /&gt;
			$parameter = new JRegistry;&lt;br /&gt;
			$parameter-&amp;gt;loadArray($array[&#039;params&#039;]);&lt;br /&gt;
			$array[&#039;params&#039;] = (string)$parameter;&lt;br /&gt;
		}&lt;br /&gt;
		return parent::bind($array, $ignore);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Overloaded load function&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param       int $pk primary key&lt;br /&gt;
	 * @param       boolean $reset reset data&lt;br /&gt;
	 * @return      boolean&lt;br /&gt;
	 * @see JTable:load&lt;br /&gt;
	 */&lt;br /&gt;
	public function load($pk = null, $reset = true) &lt;br /&gt;
	{&lt;br /&gt;
		if (parent::load($pk, $reset)) &lt;br /&gt;
		{&lt;br /&gt;
			// Convert the params field to a registry.&lt;br /&gt;
			$params = new JRegistry;&lt;br /&gt;
			$params-&amp;gt;loadJSON($this-&amp;gt;params);&lt;br /&gt;
			$this-&amp;gt;params = $params;&lt;br /&gt;
			return true;&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to compute the default name of the asset.&lt;br /&gt;
	 * The default name is in the form `table_name.id`&lt;br /&gt;
	 * where id is the value of the primary key of the table.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	string&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function _getAssetName()&lt;br /&gt;
	{&lt;br /&gt;
		$k = $this-&amp;gt;_tbl_key;&lt;br /&gt;
		return &#039;com_helloworld.message.&#039;.(int) $this-&amp;gt;$k;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to return the title to use for the asset table.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	string&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function _getAssetTitle()&lt;br /&gt;
	{&lt;br /&gt;
		return $this-&amp;gt;greeting;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get the parent asset id for the record&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	int&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function _getAssetParentId()&lt;br /&gt;
	{&lt;br /&gt;
		$asset = JTable::getInstance(&#039;Asset&#039;);&lt;br /&gt;
		$asset-&amp;gt;loadByName(&#039;com_helloworld&#039;);&lt;br /&gt;
		return $asset-&amp;gt;id;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Packaging the component ==&lt;br /&gt;
&lt;br /&gt;
Content of your code directory&lt;br /&gt;
* &#039;&#039;[[#helloworld.xml|helloworld.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_02#site/helloworld.php|site/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_02#site/controller.php|site/controller.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/views/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/views/helloworld/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#site/views/helloworld/view.html.php|site/views/helloworld/view.html.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/views/helloworld/tmpl/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_06#site/views/helloworld/tmpl/default.xml|site/views/helloworld/tmpl/default.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#site/views/helloworld/tmpl/default.php|site/views/helloworld/tmpl/default.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/models/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#site/models/helloworld.php|site/models/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/language/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/language/en-GB/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_08#site/language/en-GB/en-GB.com_helloworld.ini|site/language/en-GB/en-GB.com_helloworld.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/access.xml|admin/access.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/config.xml|admin/config.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/helloworld.php|admin/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_12#admin/controller.php|admin/controller.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/sql/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/sql/install.mysql.utf8.sql|admin/sql/install.mysql.utf8.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_06#admin/sql/uninstall.mysql.utf8.sql|admin/sql/uninstall.mysql.utf8.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/sql/updates/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/sql/updates/mysql/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#admin/sql/updates/mysql/0.0.1.sql|admin/sql/updates/mysql/0.0.1.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_06#admin/sql/install.mysql.utf8.sql|admin/sql/updates/mysql/0.0.6.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_12#admin/sql/updates/mysql/0.0.12.sql|admin/sql/updates/mysql/0.0.12.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/sql/updates/mysql/0.0.13.sql|admin/sql/updates/mysql/0.0.13.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/fields/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_12#admin/models/fields/helloworld.php|admin/models/fields/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/forms/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/models/forms/helloworld.xml|admin/models/forms/helloworld.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/models/forms/helloworld.js|admin/models/forms/helloworld.js]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/rules/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/models/rules/greeting.php|admin/models/rules/greeting.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/models/helloworld.php|admin/models/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_09#admin/models/helloworlds.php|admin/models/helloworlds.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworlds/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/views/helloworlds/view.html.php|admin/views/helloworlds/view.html.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworlds/tmpl/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/views/helloworlds/tmpl/default.php|admin/views/helloworlds/tmpl/default.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_07#admin/views/helloworlds/tmpl/default_head.php|admin/views/helloworlds/tmpl/default_head.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_07#admin/views/helloworlds/tmpl/default_body.php|admin/views/helloworlds/tmpl/default_body.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_07#admin/views/helloworlds/tmpl/default_foot.php|admin/views/helloworlds/tmpl/default_foot.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworld/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/views/helloworld/view.html.php|admin/views/helloworld/view.html.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/views/helloworld/submitbutton.js|admin/views/helloworld/submitbutton.js]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworld/tmpl/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/views/helloworld/tmpl/edit.php|admin/views/helloworld/tmpl/edit.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/helpers/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/helpers/helloworld.php|admin/helpers/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/tables/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/tables/helloworld.php|admin/tables/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/language/en-GB/en-GB.com_helloworld.ini|admin/language/en-GB/en-GB.com_helloworld.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_08#admin/language/en-GB/en-GB.com_helloworld.sys.ini|admin/language/en-GB/en-GB.com_helloworld.sys.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/controllers/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/controllers/helloworld.php|admin/controllers/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/controllers/helloworlds.php|admin/controllers/helloworlds.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_08#language/en-GB/en-GB.ini|language/en-GB/en-GB.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|media/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|media/images/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;media/images/tux-16x16.png&#039;&#039;&lt;br /&gt;
* &#039;&#039;media/images/tux-48x48.png&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create a compressed file of this directory or directly download the [http://joomlacode.org/gf/download/frsrelease/11394/58412/com_helloworld-1.6-part14.zip archive] and install it using the extension manager of Joomla!1.6. You can add a menu item of this component using the menu manager in the backend.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;helloworld.xml&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;helloworld.xml&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;component&amp;quot; version=&amp;quot;1.6.0&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;name&amp;gt;COM_HELLOWORLD&amp;lt;/name&amp;gt;&lt;br /&gt;
	&amp;lt;!-- The following elements are optional and free of formatting conttraints --&amp;gt;&lt;br /&gt;
	&amp;lt;creationDate&amp;gt;November 2009&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
	&amp;lt;author&amp;gt;John Doe&amp;lt;/author&amp;gt;&lt;br /&gt;
	&amp;lt;authorEmail&amp;gt;john.doe@example.org&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
	&amp;lt;authorUrl&amp;gt;http://www.example.org&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
	&amp;lt;copyright&amp;gt;Copyright Info&amp;lt;/copyright&amp;gt;&lt;br /&gt;
	&amp;lt;license&amp;gt;License Info&amp;lt;/license&amp;gt;&lt;br /&gt;
	&amp;lt;!--  The version string is recorded in the components table --&amp;gt;&lt;br /&gt;
	&amp;lt;version&amp;gt;0.0.14&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;!-- The description is optional and defaults to the name --&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;COM_HELLOWORLD_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;install&amp;gt; &amp;lt;!-- Runs on install --&amp;gt;&lt;br /&gt;
		&amp;lt;sql&amp;gt;&lt;br /&gt;
			&amp;lt;file driver=&amp;quot;mysql&amp;quot; charset=&amp;quot;utf8&amp;quot;&amp;gt;sql/install.mysql.utf8.sql&amp;lt;/file&amp;gt;&lt;br /&gt;
		&amp;lt;/sql&amp;gt;&lt;br /&gt;
	&amp;lt;/install&amp;gt;&lt;br /&gt;
	&amp;lt;uninstall&amp;gt; &amp;lt;!-- Runs on uninstall --&amp;gt;&lt;br /&gt;
		&amp;lt;sql&amp;gt;&lt;br /&gt;
			&amp;lt;file driver=&amp;quot;mysql&amp;quot; charset=&amp;quot;utf8&amp;quot;&amp;gt;sql/uninstall.mysql.utf8.sql&amp;lt;/file&amp;gt;&lt;br /&gt;
		&amp;lt;/sql&amp;gt;&lt;br /&gt;
	&amp;lt;/uninstall&amp;gt;&lt;br /&gt;
	&amp;lt;update&amp;gt; &amp;lt;!-- Runs on update; New in 1.6 --&amp;gt;&lt;br /&gt;
		&amp;lt;schemas&amp;gt;&lt;br /&gt;
			&amp;lt;schemapath type=&amp;quot;mysql&amp;quot;&amp;gt;sql/updates/mysql&amp;lt;/schemapath&amp;gt;&lt;br /&gt;
		&amp;lt;/schemas&amp;gt;&lt;br /&gt;
	&amp;lt;/update&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;!-- Site Main File Copy Section --&amp;gt;&lt;br /&gt;
	&amp;lt;!-- Note the folder attribute: This attribute describes the folder&lt;br /&gt;
		to copy FROM in the package to install therefore files copied&lt;br /&gt;
		in this section are copied from /site/ in the package --&amp;gt;&lt;br /&gt;
	&amp;lt;files folder=&amp;quot;site&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helloworld.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;controller.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;views&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;models&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;com_helloworld&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;administration&amp;gt;&lt;br /&gt;
		&amp;lt;!-- Administration Menu Section --&amp;gt;&lt;br /&gt;
		&amp;lt;menu img=&amp;quot;../media/com_helloworld/images/tux-16x16.png&amp;quot;&amp;gt;COM_HELLOWORLD_MENU&amp;lt;/menu&amp;gt;&lt;br /&gt;
		&amp;lt;!-- Administration Main File Copy Section --&amp;gt;&lt;br /&gt;
		&amp;lt;!-- Note the folder attribute: This attribute describes the folder&lt;br /&gt;
			to copy FROM in the package to install therefore files copied&lt;br /&gt;
			in this section are copied from /admin/ in the package --&amp;gt;&lt;br /&gt;
		&amp;lt;files folder=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;!-- Admin Main File Copy Section --&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;config.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;access.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;helloworld.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;controller.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;!-- SQL files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;sql&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- tables files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;tables&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- models files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;models&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- views files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;views&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- controllers files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;controllers&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- helpers files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;helpers&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;languages folder=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;language/en-GB/en-GB.com_helloworld.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
			&amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;language/en-GB/en-GB.com_helloworld.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
		&amp;lt;/languages&amp;gt;&lt;br /&gt;
	&amp;lt;/administration&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Navigate ==&lt;br /&gt;
&lt;br /&gt;
[[Developing a Model-View-Controller (MVC) Component for Joomla!1.6 - Part 13|Prev: Adding configuration]]&lt;br /&gt;
[[Developing a Model-View-Controller (MVC) Component for Joomla!1.6 - Part 15|Next: Adding an install/uninstall/update script file]]&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
*[[User:cdemko|Christophe Demko]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[category:Joomla! 1.6]]&lt;br /&gt;
[[category:Manual]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:Developing_a_MVC_Component/Adding_ACL&amp;diff=36666</id>
		<title>Archived:Developing a MVC Component/Adding ACL</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:Developing_a_MVC_Component/Adding_ACL&amp;diff=36666"/>
		<updated>2011-02-02T19:34:41Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: Reworded the &amp;quot;Restricting access to the component&amp;quot; paragraph.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial is for {{JVer|1.6}}&lt;br /&gt;
&lt;br /&gt;
== Articles in this series ==&lt;br /&gt;
{{Chunk:Developing a Model-View-Controller (MVC) Component for Joomla!1.6 - Contents}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This tutorial is part of the [[Developing a Model-View-Controller (MVC) Component for Joomla!1.6]] tutorial. You are encouraged to read the previous parts of the tutorial before reading this.&lt;br /&gt;
&lt;br /&gt;
== Describing the ACL ==&lt;br /&gt;
Each component has its own ACL. They can be described in an &#039;&#039;access.xml&#039;&#039; file located at the root of the &#039;&#039;admin&#039;&#039; folder. This file describes the ACL for the com_helloworld component in a different section. In this example, we have chosen to separate the different ACL into two sections: components and messages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/access.xml&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/access.xml&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;access component=&amp;quot;com_helloworld&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;section name=&amp;quot;component&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.admin&amp;quot; title=&amp;quot;JACTION_ADMIN&amp;quot; description=&amp;quot;JACTION_ADMIN_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.manage&amp;quot; title=&amp;quot;JACTION_MANAGE&amp;quot; description=&amp;quot;JACTION_MANAGE_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.create&amp;quot; title=&amp;quot;JACTION_CREATE&amp;quot; description=&amp;quot;JACTION_CREATE_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.delete&amp;quot; title=&amp;quot;JACTION_DELETE&amp;quot; description=&amp;quot;JACTION_DELETE_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.edit&amp;quot; title=&amp;quot;JACTION_EDIT&amp;quot; description=&amp;quot;JACTION_EDIT_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/section&amp;gt;&lt;br /&gt;
	&amp;lt;section name=&amp;quot;message&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.delete&amp;quot; title=&amp;quot;JACTION_DELETE&amp;quot; description=&amp;quot;COM_HELLOWORLD_ACCESS_DELETE_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.edit&amp;quot; title=&amp;quot;JACTION_EDIT&amp;quot; description=&amp;quot;COM_HELLOWORLD_ACCESS_EDIT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/access&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Restricting access to the component ==&lt;br /&gt;
&lt;br /&gt;
The main idea in ACL is to restrict actions to groups of users. The first action to be restricted is access to the component itself. With your favorite file editor, edit the &#039;&#039;admin/helloworld.php&#039;&#039; file and it these lines&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/helloworld.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/helloworld.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// Access check.&lt;br /&gt;
if (!JFactory::getUser()-&amp;gt;authorise(&#039;core.manage&#039;, &#039;com_helloworld&#039;)) &lt;br /&gt;
{&lt;br /&gt;
	return JError::raiseWarning(404, JText::_(&#039;JERROR_ALERTNOAUTHOR&#039;));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// require helper file&lt;br /&gt;
JLoader::register(&#039;HelloWorldHelper&#039;, dirname(__FILE__) . DS . &#039;helpers&#039; . DS . &#039;helloworld.php&#039;);&lt;br /&gt;
&lt;br /&gt;
// import joomla controller library&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
// Get an instance of the controller prefixed by HelloWorld&lt;br /&gt;
$controller = JController::getInstance(&#039;HelloWorld&#039;);&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
 &lt;br /&gt;
// Redirect if set by the controller&lt;br /&gt;
$controller-&amp;gt;redirect();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Displaying only the right toolbar buttons ==&lt;br /&gt;
&lt;br /&gt;
The toolbar buttons that have to displayed depends on the ACL rights.&lt;br /&gt;
&lt;br /&gt;
In the &#039;&#039;admin/views/helloworlds/view.html.php&#039;&#039;, put this code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/views/helloworlds/view.html.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/views/helloworlds/view.html.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// import Joomla view library&lt;br /&gt;
jimport(&#039;joomla.application.component.view&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * HelloWorlds View&lt;br /&gt;
 */&lt;br /&gt;
class HelloWorldViewHelloWorlds extends JView&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * HelloWorlds view display method&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	function display($tpl = null) &lt;br /&gt;
	{&lt;br /&gt;
		// Get data from the model&lt;br /&gt;
		$items = $this-&amp;gt;get(&#039;Items&#039;);&lt;br /&gt;
		$pagination = $this-&amp;gt;get(&#039;Pagination&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Check for errors.&lt;br /&gt;
		if (count($errors = $this-&amp;gt;get(&#039;Errors&#039;))) &lt;br /&gt;
		{&lt;br /&gt;
			JError::raiseError(500, implode(&#039;&amp;lt;br /&amp;gt;&#039;, $errors));&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		// Assign data to the view&lt;br /&gt;
		$this-&amp;gt;items = $items;&lt;br /&gt;
		$this-&amp;gt;pagination = $pagination;&lt;br /&gt;
&lt;br /&gt;
		// Set the toolbar&lt;br /&gt;
		$this-&amp;gt;addToolBar();&lt;br /&gt;
&lt;br /&gt;
		// Display the template&lt;br /&gt;
		parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
		// Set the document&lt;br /&gt;
		$this-&amp;gt;setDocument();&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Setting the toolbar&lt;br /&gt;
	 */&lt;br /&gt;
	protected function addToolBar() &lt;br /&gt;
	{&lt;br /&gt;
		$canDo = HelloWorldHelper::getActions();&lt;br /&gt;
		JToolBarHelper::title(JText::_(&#039;COM_HELLOWORLD_MANAGER_HELLOWORLDS&#039;), &#039;helloworld&#039;);&lt;br /&gt;
		if ($canDo-&amp;gt;get(&#039;core.create&#039;)) &lt;br /&gt;
		{&lt;br /&gt;
			JToolBarHelper::addNew(&#039;helloworld.add&#039;, &#039;JTOOLBAR_NEW&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		if ($canDo-&amp;gt;get(&#039;core.edit&#039;)) &lt;br /&gt;
		{&lt;br /&gt;
			JToolBarHelper::editList(&#039;helloworld.edit&#039;, &#039;JTOOLBAR_EDIT&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		if ($canDo-&amp;gt;get(&#039;core.delete&#039;)) &lt;br /&gt;
		{&lt;br /&gt;
			JToolBarHelper::deleteList(&#039;&#039;, &#039;helloworld.delete&#039;, &#039;JTOOLBAR_DELETE&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		if ($canDo-&amp;gt;get(&#039;core.admin&#039;)) &lt;br /&gt;
		{&lt;br /&gt;
			JToolBarHelper::divider();&lt;br /&gt;
			JToolBarHelper::preferences(&#039;com_helloworld&#039;);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to set up the document properties&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	protected function setDocument() &lt;br /&gt;
	{&lt;br /&gt;
		$document = JFactory::getDocument();&lt;br /&gt;
		$document-&amp;gt;setTitle(JText::_(&#039;COM_HELLOWORLD_ADMINISTRATION&#039;));&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;&#039;admin/views/helloworld/view.html.php&#039;&#039;, put this code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/views/helloworld/view.html.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/views/helloworld/view.html.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// import Joomla view library&lt;br /&gt;
jimport(&#039;joomla.application.component.view&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * HelloWorld View&lt;br /&gt;
 */&lt;br /&gt;
class HelloWorldViewHelloWorld extends JView&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * display method of Hello view&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	public function display($tpl = null) &lt;br /&gt;
	{&lt;br /&gt;
		// get the Data&lt;br /&gt;
		$form = $this-&amp;gt;get(&#039;Form&#039;);&lt;br /&gt;
		$item = $this-&amp;gt;get(&#039;Item&#039;);&lt;br /&gt;
		$script = $this-&amp;gt;get(&#039;Script&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Check for errors.&lt;br /&gt;
		if (count($errors = $this-&amp;gt;get(&#039;Errors&#039;))) &lt;br /&gt;
		{&lt;br /&gt;
			JError::raiseError(500, implode(&#039;&amp;lt;br /&amp;gt;&#039;, $errors));&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		// Assign the Data&lt;br /&gt;
		$this-&amp;gt;form = $form;&lt;br /&gt;
		$this-&amp;gt;item = $item;&lt;br /&gt;
		$this-&amp;gt;script = $script;&lt;br /&gt;
&lt;br /&gt;
		// Set the toolbar&lt;br /&gt;
		$this-&amp;gt;addToolBar();&lt;br /&gt;
&lt;br /&gt;
		// Display the template&lt;br /&gt;
		parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
		// Set the document&lt;br /&gt;
		$this-&amp;gt;setDocument();&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Setting the toolbar&lt;br /&gt;
	 */&lt;br /&gt;
	protected function addToolBar() &lt;br /&gt;
	{&lt;br /&gt;
		JRequest::setVar(&#039;hidemainmenu&#039;, true);&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
		$userId = $user-&amp;gt;id;&lt;br /&gt;
		$isNew = $this-&amp;gt;item-&amp;gt;id == 0;&lt;br /&gt;
		$canDo = HelloWorldHelper::getActions($this-&amp;gt;item-&amp;gt;id);&lt;br /&gt;
		JToolBarHelper::title($isNew ? JText::_(&#039;COM_HELLOWORLD_MANAGER_HELLOWORLD_NEW&#039;) : JText::_(&#039;COM_HELLOWORLD_MANAGER_HELLOWORLD_EDIT&#039;), &#039;helloworld&#039;);&lt;br /&gt;
		// Built the actions for new and existing records.&lt;br /&gt;
		if ($isNew) &lt;br /&gt;
		{&lt;br /&gt;
			// For new records, check the create permission.&lt;br /&gt;
			if ($canDo-&amp;gt;get(&#039;core.create&#039;)) &lt;br /&gt;
			{&lt;br /&gt;
				JToolBarHelper::apply(&#039;helloworld.apply&#039;, &#039;JTOOLBAR_APPLY&#039;);&lt;br /&gt;
				JToolBarHelper::save(&#039;helloworld.save&#039;, &#039;JTOOLBAR_SAVE&#039;);&lt;br /&gt;
				JToolBarHelper::custom(&#039;helloworld.save2new&#039;, &#039;save-new.png&#039;, &#039;save-new_f2.png&#039;, &#039;JTOOLBAR_SAVE_AND_NEW&#039;, false);&lt;br /&gt;
			}&lt;br /&gt;
			JToolBarHelper::cancel(&#039;helloworld.cancel&#039;, &#039;JTOOLBAR_CANCEL&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			if ($canDo-&amp;gt;get(&#039;core.edit&#039;))&lt;br /&gt;
			{&lt;br /&gt;
				// We can save the new record&lt;br /&gt;
				JToolBarHelper::apply(&#039;helloworld.apply&#039;, &#039;JTOOLBAR_APPLY&#039;);&lt;br /&gt;
				JToolBarHelper::save(&#039;helloworld.save&#039;, &#039;JTOOLBAR_SAVE&#039;);&lt;br /&gt;
&lt;br /&gt;
				// We can save this record, but check the create permission to see if we can return to make a new one.&lt;br /&gt;
				if ($canDo-&amp;gt;get(&#039;core.create&#039;)) &lt;br /&gt;
				{&lt;br /&gt;
					JToolBarHelper::custom(&#039;helloworld.save2new&#039;, &#039;save-new.png&#039;, &#039;save-new_f2.png&#039;, &#039;JTOOLBAR_SAVE_AND_NEW&#039;, false);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
			if ($canDo-&amp;gt;get(&#039;core.create&#039;)) &lt;br /&gt;
			{&lt;br /&gt;
				JToolBarHelper::custom(&#039;helloworld.save2copy&#039;, &#039;save-copy.png&#039;, &#039;save-copy_f2.png&#039;, &#039;JTOOLBAR_SAVE_AS_COPY&#039;, false);&lt;br /&gt;
			}&lt;br /&gt;
			JToolBarHelper::cancel(&#039;helloworld.cancel&#039;, &#039;JTOOLBAR_CLOSE&#039;);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to set up the document properties&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	protected function setDocument() &lt;br /&gt;
	{&lt;br /&gt;
		$isNew = $this-&amp;gt;item-&amp;gt;id == 0;&lt;br /&gt;
		$document = JFactory::getDocument();&lt;br /&gt;
		$document-&amp;gt;setTitle($isNew ? JText::_(&#039;COM_HELLOWORLD_HELLOWORLD_CREATING&#039;) : JText::_(&#039;COM_HELLOWORLD_HELLOWORLD_EDITING&#039;));&lt;br /&gt;
		$document-&amp;gt;addScript(JURI::root() . $this-&amp;gt;script);&lt;br /&gt;
		$document-&amp;gt;addScript(JURI::root() . &amp;quot;/administrator/components/com_helloworld/views/helloworld/submitbutton.js&amp;quot;);&lt;br /&gt;
		JText::script(&#039;COM_HELLOWORLD_HELLOWORLD_ERROR_UNACCEPTABLE&#039;);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These two files use the &#039;&#039;getActions&#039;&#039; method defined in the &#039;&#039;admin/helpers/helloworld.php&#039;&#039; file&lt;br /&gt;
&lt;br /&gt;
In the &#039;&#039;admin/helpers/helloworld.php&#039;&#039;, put this code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/helpers/helloworld.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/helpers/helloworld.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * HelloWorld component helper.&lt;br /&gt;
 */&lt;br /&gt;
abstract class HelloWorldHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Configure the Linkbar.&lt;br /&gt;
	 */&lt;br /&gt;
	public static function addSubmenu($submenu) &lt;br /&gt;
	{&lt;br /&gt;
		JSubMenuHelper::addEntry(JText::_(&#039;COM_HELLOWORLD_SUBMENU_MESSAGES&#039;), &#039;index.php?option=com_helloworld&#039;, $submenu == &#039;messages&#039;);&lt;br /&gt;
		JSubMenuHelper::addEntry(JText::_(&#039;COM_HELLOWORLD_SUBMENU_CATEGORIES&#039;), &#039;index.php?option=com_categories&amp;amp;view=categories&amp;amp;extension=com_helloworld&#039;, $submenu == &#039;categories&#039;);&lt;br /&gt;
		// set some global property&lt;br /&gt;
		$document = JFactory::getDocument();&lt;br /&gt;
		$document-&amp;gt;addStyleDeclaration(&#039;.icon-48-helloworld {background-image: url(../media/com_helloworld/images/tux-48x48.png);}&#039;);&lt;br /&gt;
		if ($submenu == &#039;categories&#039;) &lt;br /&gt;
		{&lt;br /&gt;
			$document-&amp;gt;setTitle(JText::_(&#039;COM_HELLOWORLD_ADMINISTRATION_CATEGORIES&#039;));&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get the actions&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getActions($messageId = 0)&lt;br /&gt;
	{&lt;br /&gt;
		$user	= JFactory::getUser();&lt;br /&gt;
		$result	= new JObject;&lt;br /&gt;
&lt;br /&gt;
		if (empty($messageId)) {&lt;br /&gt;
			$assetName = &#039;com_helloworld&#039;;&lt;br /&gt;
		}&lt;br /&gt;
		else {&lt;br /&gt;
			$assetName = &#039;com_helloworld.message.&#039;.(int) $messageId;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$actions = array(&lt;br /&gt;
			&#039;core.admin&#039;, &#039;core.manage&#039;, &#039;core.create&#039;, &#039;core.edit&#039;, &#039;core.delete&#039;&lt;br /&gt;
		);&lt;br /&gt;
&lt;br /&gt;
		foreach ($actions as $action) {&lt;br /&gt;
			$result-&amp;gt;set($action,	$user-&amp;gt;authorise($action, $assetName));&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Adding permissions settings in the component preferences ==&lt;br /&gt;
Since we now use ACL rights in our component, we need to set them at the component level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/config.xml&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/config.xml&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;config&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset&lt;br /&gt;
		name=&amp;quot;greetings&amp;quot;&lt;br /&gt;
		label=&amp;quot;COM_HELLOWORLD_CONFIG_GREETING_SETTINGS_LABEL&amp;quot;&lt;br /&gt;
		description=&amp;quot;COM_HELLOWORLD_CONFIG_GREETING_SETTINGS_DESC&amp;quot;&lt;br /&gt;
	&amp;gt;&lt;br /&gt;
		&amp;lt;field&lt;br /&gt;
			name=&amp;quot;show_category&amp;quot;&lt;br /&gt;
			type=&amp;quot;radio&amp;quot;&lt;br /&gt;
			label=&amp;quot;COM_HELLOWORLD_HELLOWORLD_FIELD_SHOW_CATEGORY_LABEL&amp;quot;&lt;br /&gt;
			description=&amp;quot;COM_HELLOWORLD_HELLOWORLD_FIELD_SHOW_CATEGORY_DESC&amp;quot;&lt;br /&gt;
			default=&amp;quot;0&amp;quot;&lt;br /&gt;
		&amp;gt;&lt;br /&gt;
			&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JHIDE&amp;lt;/option&amp;gt;&lt;br /&gt;
			&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JSHOW&amp;lt;/option&amp;gt;&lt;br /&gt;
		&amp;lt;/field&amp;gt;&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset&lt;br /&gt;
		name=&amp;quot;permissions&amp;quot;&lt;br /&gt;
		label=&amp;quot;JCONFIG_PERMISSIONS_LABEL&amp;quot;&lt;br /&gt;
		description=&amp;quot;JCONFIG_PERMISSIONS_DESC&amp;quot;&lt;br /&gt;
	&amp;gt;&lt;br /&gt;
		&amp;lt;field&lt;br /&gt;
			name=&amp;quot;rules&amp;quot;&lt;br /&gt;
			type=&amp;quot;rules&amp;quot;&lt;br /&gt;
			label=&amp;quot;JCONFIG_PERMISSIONS_LABEL&amp;quot;&lt;br /&gt;
			class=&amp;quot;inputbox&amp;quot;&lt;br /&gt;
			validate=&amp;quot;rules&amp;quot;&lt;br /&gt;
			filter=&amp;quot;rules&amp;quot;&lt;br /&gt;
			component=&amp;quot;com_helloworld&amp;quot;&lt;br /&gt;
			section=&amp;quot;component&amp;quot;&lt;br /&gt;
		/&amp;gt;&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/config&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting the value in the assets table ==&lt;br /&gt;
&lt;br /&gt;
In order to set asset for each message, we have to do two things.&lt;br /&gt;
&lt;br /&gt;
First, we precise that the &#039;core.edit&#039; ACL right has to be taken from the message itself, then from the component&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/models/helloworld.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/models/helloworld.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// import Joomla modelform library&lt;br /&gt;
jimport(&#039;joomla.application.component.modeladmin&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * HelloWorld Model&lt;br /&gt;
 */&lt;br /&gt;
class HelloWorldModelHelloWorld extends JModelAdmin&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method override to check if you can edit an existing record.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param	array	$data	An array of input data.&lt;br /&gt;
	 * @param	string	$key	The name of the key for the primary key.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	boolean&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function allowEdit($data = array(), $key = &#039;id&#039;)&lt;br /&gt;
	{&lt;br /&gt;
		// Check specific edit permission then general edit permission.&lt;br /&gt;
		return JFactory::getUser()-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_helloworld.message.&#039;.((int) isset($data[$key]) ? $data[$key] : 0)) or parent::allowEdit($data, $key);&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Returns a reference to the a Table object, always creating it.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param	type	The table type to instantiate&lt;br /&gt;
	 * @param	string	A prefix for the table class name. Optional.&lt;br /&gt;
	 * @param	array	Configuration array for model. Optional.&lt;br /&gt;
	 * @return	JTable	A database object&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	public function getTable($type = &#039;HelloWorld&#039;, $prefix = &#039;HelloWorldTable&#039;, $config = array()) &lt;br /&gt;
	{&lt;br /&gt;
		return JTable::getInstance($type, $prefix, $config);&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to get the record form.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param	array	$data		Data for the form.&lt;br /&gt;
	 * @param	boolean	$loadData	True if the form is to load its own data (default case), false if not.&lt;br /&gt;
	 * @return	mixed	A JForm object on success, false on failure&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	public function getForm($data = array(), $loadData = true) &lt;br /&gt;
	{&lt;br /&gt;
		// Get the form.&lt;br /&gt;
		$form = $this-&amp;gt;loadForm(&#039;com_helloworld.helloworld&#039;, &#039;helloworld&#039;, array(&#039;control&#039; =&amp;gt; &#039;jform&#039;, &#039;load_data&#039; =&amp;gt; $loadData));&lt;br /&gt;
		if (empty($form)) &lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		return $form;&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to get the script that have to be included on the form&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return string	Script files&lt;br /&gt;
	 */&lt;br /&gt;
	public function getScript() &lt;br /&gt;
	{&lt;br /&gt;
		return &#039;administrator/components/com_helloworld/models/forms/helloworld.js&#039;;&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to get the data that should be injected in the form.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	mixed	The data for the form.&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function loadFormData() &lt;br /&gt;
	{&lt;br /&gt;
		// Check the session for previously entered form data.&lt;br /&gt;
		$data = JFactory::getApplication()-&amp;gt;getUserState(&#039;com_helloworld.edit.helloworld.data&#039;, array());&lt;br /&gt;
		if (empty($data)) &lt;br /&gt;
		{&lt;br /&gt;
			$data = $this-&amp;gt;getItem();&lt;br /&gt;
		}&lt;br /&gt;
		return $data;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Second, we precise the asset name, asset title and asset parent in the helloworld table&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/tables/helloworld.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/tables/helloworld.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// No direct access&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// import Joomla table library&lt;br /&gt;
jimport(&#039;joomla.database.table&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Hello Table class&lt;br /&gt;
 */&lt;br /&gt;
class HelloWorldTableHelloWorld extends JTable&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Constructor&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param object Database connector object&lt;br /&gt;
	 */&lt;br /&gt;
	function __construct(&amp;amp;$db) &lt;br /&gt;
	{&lt;br /&gt;
		parent::__construct(&#039;#__helloworld&#039;, &#039;id&#039;, $db);&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Overloaded bind function&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param       array           named array&lt;br /&gt;
	 * @return      null|string     null is operation was satisfactory, otherwise returns an error&lt;br /&gt;
	 * @see JTable:bind&lt;br /&gt;
	 * @since 1.5&lt;br /&gt;
	 */&lt;br /&gt;
	public function bind($array, $ignore = &#039;&#039;) &lt;br /&gt;
	{&lt;br /&gt;
		if (isset($array[&#039;params&#039;]) &amp;amp;&amp;amp; is_array($array[&#039;params&#039;])) &lt;br /&gt;
		{&lt;br /&gt;
			// Convert the params field to a string.&lt;br /&gt;
			$parameter = new JRegistry;&lt;br /&gt;
			$parameter-&amp;gt;loadArray($array[&#039;params&#039;]);&lt;br /&gt;
			$array[&#039;params&#039;] = (string)$parameter;&lt;br /&gt;
		}&lt;br /&gt;
		return parent::bind($array, $ignore);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Overloaded load function&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param       int $pk primary key&lt;br /&gt;
	 * @param       boolean $reset reset data&lt;br /&gt;
	 * @return      boolean&lt;br /&gt;
	 * @see JTable:load&lt;br /&gt;
	 */&lt;br /&gt;
	public function load($pk = null, $reset = true) &lt;br /&gt;
	{&lt;br /&gt;
		if (parent::load($pk, $reset)) &lt;br /&gt;
		{&lt;br /&gt;
			// Convert the params field to a registry.&lt;br /&gt;
			$params = new JRegistry;&lt;br /&gt;
			$params-&amp;gt;loadJSON($this-&amp;gt;params);&lt;br /&gt;
			$this-&amp;gt;params = $params;&lt;br /&gt;
			return true;&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to compute the default name of the asset.&lt;br /&gt;
	 * The default name is in the form `table_name.id`&lt;br /&gt;
	 * where id is the value of the primary key of the table.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	string&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function _getAssetName()&lt;br /&gt;
	{&lt;br /&gt;
		$k = $this-&amp;gt;_tbl_key;&lt;br /&gt;
		return &#039;com_helloworld.message.&#039;.(int) $this-&amp;gt;$k;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to return the title to use for the asset table.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	string&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function _getAssetTitle()&lt;br /&gt;
	{&lt;br /&gt;
		return $this-&amp;gt;greeting;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get the parent asset id for the record&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	int&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function _getAssetParentId()&lt;br /&gt;
	{&lt;br /&gt;
		$asset = JTable::getInstance(&#039;Asset&#039;);&lt;br /&gt;
		$asset-&amp;gt;loadByName(&#039;com_helloworld&#039;);&lt;br /&gt;
		return $asset-&amp;gt;id;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Packaging the component ==&lt;br /&gt;
&lt;br /&gt;
Content of your code directory&lt;br /&gt;
* &#039;&#039;[[#helloworld.xml|helloworld.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_02#site/helloworld.php|site/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_02#site/controller.php|site/controller.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/views/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/views/helloworld/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#site/views/helloworld/view.html.php|site/views/helloworld/view.html.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/views/helloworld/tmpl/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_06#site/views/helloworld/tmpl/default.xml|site/views/helloworld/tmpl/default.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#site/views/helloworld/tmpl/default.php|site/views/helloworld/tmpl/default.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/models/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#site/models/helloworld.php|site/models/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/language/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/language/en-GB/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_08#site/language/en-GB/en-GB.com_helloworld.ini|site/language/en-GB/en-GB.com_helloworld.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/access.xml|admin/access.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/config.xml|admin/config.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/helloworld.php|admin/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_12#admin/controller.php|admin/controller.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/sql/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/sql/install.mysql.utf8.sql|admin/sql/install.mysql.utf8.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_06#admin/sql/uninstall.mysql.utf8.sql|admin/sql/uninstall.mysql.utf8.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/sql/updates/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/sql/updates/mysql/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#admin/sql/updates/mysql/0.0.1.sql|admin/sql/updates/mysql/0.0.1.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_06#admin/sql/install.mysql.utf8.sql|admin/sql/updates/mysql/0.0.6.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_12#admin/sql/updates/mysql/0.0.12.sql|admin/sql/updates/mysql/0.0.12.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/sql/updates/mysql/0.0.13.sql|admin/sql/updates/mysql/0.0.13.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/fields/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_12#admin/models/fields/helloworld.php|admin/models/fields/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/forms/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/models/forms/helloworld.xml|admin/models/forms/helloworld.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/models/forms/helloworld.js|admin/models/forms/helloworld.js]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/rules/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/models/rules/greeting.php|admin/models/rules/greeting.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/models/helloworld.php|admin/models/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_09#admin/models/helloworlds.php|admin/models/helloworlds.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworlds/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/views/helloworlds/view.html.php|admin/views/helloworlds/view.html.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworlds/tmpl/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/views/helloworlds/tmpl/default.php|admin/views/helloworlds/tmpl/default.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_07#admin/views/helloworlds/tmpl/default_head.php|admin/views/helloworlds/tmpl/default_head.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_07#admin/views/helloworlds/tmpl/default_body.php|admin/views/helloworlds/tmpl/default_body.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_07#admin/views/helloworlds/tmpl/default_foot.php|admin/views/helloworlds/tmpl/default_foot.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworld/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/views/helloworld/view.html.php|admin/views/helloworld/view.html.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/views/helloworld/submitbutton.js|admin/views/helloworld/submitbutton.js]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworld/tmpl/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/views/helloworld/tmpl/edit.php|admin/views/helloworld/tmpl/edit.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/helpers/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/helpers/helloworld.php|admin/helpers/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/tables/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/tables/helloworld.php|admin/tables/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/language/en-GB/en-GB.com_helloworld.ini|admin/language/en-GB/en-GB.com_helloworld.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_08#admin/language/en-GB/en-GB.com_helloworld.sys.ini|admin/language/en-GB/en-GB.com_helloworld.sys.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/controllers/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/controllers/helloworld.php|admin/controllers/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/controllers/helloworlds.php|admin/controllers/helloworlds.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_08#language/en-GB/en-GB.ini|language/en-GB/en-GB.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|media/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|media/images/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;media/images/tux-16x16.png&#039;&#039;&lt;br /&gt;
* &#039;&#039;media/images/tux-48x48.png&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create a compressed file of this directory or directly download the [http://joomlacode.org/gf/download/frsrelease/11394/58412/com_helloworld-1.6-part14.zip archive] and install it using the extension manager of Joomla!1.6. You can add a menu item of this component using the menu manager in the backend.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;helloworld.xml&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;helloworld.xml&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;component&amp;quot; version=&amp;quot;1.6.0&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;name&amp;gt;COM_HELLOWORLD&amp;lt;/name&amp;gt;&lt;br /&gt;
	&amp;lt;!-- The following elements are optional and free of formatting conttraints --&amp;gt;&lt;br /&gt;
	&amp;lt;creationDate&amp;gt;November 2009&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
	&amp;lt;author&amp;gt;John Doe&amp;lt;/author&amp;gt;&lt;br /&gt;
	&amp;lt;authorEmail&amp;gt;john.doe@example.org&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
	&amp;lt;authorUrl&amp;gt;http://www.example.org&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
	&amp;lt;copyright&amp;gt;Copyright Info&amp;lt;/copyright&amp;gt;&lt;br /&gt;
	&amp;lt;license&amp;gt;License Info&amp;lt;/license&amp;gt;&lt;br /&gt;
	&amp;lt;!--  The version string is recorded in the components table --&amp;gt;&lt;br /&gt;
	&amp;lt;version&amp;gt;0.0.14&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;!-- The description is optional and defaults to the name --&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;COM_HELLOWORLD_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;install&amp;gt; &amp;lt;!-- Runs on install --&amp;gt;&lt;br /&gt;
		&amp;lt;sql&amp;gt;&lt;br /&gt;
			&amp;lt;file driver=&amp;quot;mysql&amp;quot; charset=&amp;quot;utf8&amp;quot;&amp;gt;sql/install.mysql.utf8.sql&amp;lt;/file&amp;gt;&lt;br /&gt;
		&amp;lt;/sql&amp;gt;&lt;br /&gt;
	&amp;lt;/install&amp;gt;&lt;br /&gt;
	&amp;lt;uninstall&amp;gt; &amp;lt;!-- Runs on uninstall --&amp;gt;&lt;br /&gt;
		&amp;lt;sql&amp;gt;&lt;br /&gt;
			&amp;lt;file driver=&amp;quot;mysql&amp;quot; charset=&amp;quot;utf8&amp;quot;&amp;gt;sql/uninstall.mysql.utf8.sql&amp;lt;/file&amp;gt;&lt;br /&gt;
		&amp;lt;/sql&amp;gt;&lt;br /&gt;
	&amp;lt;/uninstall&amp;gt;&lt;br /&gt;
	&amp;lt;update&amp;gt; &amp;lt;!-- Runs on update; New in 1.6 --&amp;gt;&lt;br /&gt;
		&amp;lt;schemas&amp;gt;&lt;br /&gt;
			&amp;lt;schemapath type=&amp;quot;mysql&amp;quot;&amp;gt;sql/updates/mysql&amp;lt;/schemapath&amp;gt;&lt;br /&gt;
		&amp;lt;/schemas&amp;gt;&lt;br /&gt;
	&amp;lt;/update&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;!-- Site Main File Copy Section --&amp;gt;&lt;br /&gt;
	&amp;lt;!-- Note the folder attribute: This attribute describes the folder&lt;br /&gt;
		to copy FROM in the package to install therefore files copied&lt;br /&gt;
		in this section are copied from /site/ in the package --&amp;gt;&lt;br /&gt;
	&amp;lt;files folder=&amp;quot;site&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helloworld.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;controller.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;views&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;models&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;com_helloworld&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;administration&amp;gt;&lt;br /&gt;
		&amp;lt;!-- Administration Menu Section --&amp;gt;&lt;br /&gt;
		&amp;lt;menu img=&amp;quot;../media/com_helloworld/images/tux-16x16.png&amp;quot;&amp;gt;COM_HELLOWORLD_MENU&amp;lt;/menu&amp;gt;&lt;br /&gt;
		&amp;lt;!-- Administration Main File Copy Section --&amp;gt;&lt;br /&gt;
		&amp;lt;!-- Note the folder attribute: This attribute describes the folder&lt;br /&gt;
			to copy FROM in the package to install therefore files copied&lt;br /&gt;
			in this section are copied from /admin/ in the package --&amp;gt;&lt;br /&gt;
		&amp;lt;files folder=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;!-- Admin Main File Copy Section --&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;config.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;access.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;helloworld.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;controller.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;!-- SQL files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;sql&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- tables files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;tables&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- models files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;models&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- views files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;views&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- controllers files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;controllers&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- helpers files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;helpers&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;languages folder=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;language/en-GB/en-GB.com_helloworld.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
			&amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;language/en-GB/en-GB.com_helloworld.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
		&amp;lt;/languages&amp;gt;&lt;br /&gt;
	&amp;lt;/administration&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Navigate ==&lt;br /&gt;
&lt;br /&gt;
[[Developing a Model-View-Controller (MVC) Component for Joomla!1.6 - Part 13|Prev: Adding configuration]]&lt;br /&gt;
[[Developing a Model-View-Controller (MVC) Component for Joomla!1.6 - Part 15|Next: Adding an install/uninstall/update script file]]&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
*[[User:cdemko|Christophe Demko]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[category:Joomla! 1.6]]&lt;br /&gt;
[[category:Manual]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:Developing_a_MVC_Component/Adding_ACL&amp;diff=36665</id>
		<title>Archived:Developing a MVC Component/Adding ACL</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:Developing_a_MVC_Component/Adding_ACL&amp;diff=36665"/>
		<updated>2011-02-02T19:31:40Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: Reworded the &amp;quot;Describing the ACL&amp;quot; paragraph.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial is for {{JVer|1.6}}&lt;br /&gt;
&lt;br /&gt;
== Articles in this series ==&lt;br /&gt;
{{Chunk:Developing a Model-View-Controller (MVC) Component for Joomla!1.6 - Contents}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This tutorial is part of the [[Developing a Model-View-Controller (MVC) Component for Joomla!1.6]] tutorial. You are encouraged to read the previous parts of the tutorial before reading this.&lt;br /&gt;
&lt;br /&gt;
== Describing the ACL ==&lt;br /&gt;
Each component has its own ACL. They can be described in an &#039;&#039;access.xml&#039;&#039; file located at the root of the &#039;&#039;admin&#039;&#039; folder. This file describes the ACL for the com_helloworld component in a different section. In this example, we have chosen to separate the different ACL into two sections: components and messages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/access.xml&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/access.xml&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;access component=&amp;quot;com_helloworld&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;section name=&amp;quot;component&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.admin&amp;quot; title=&amp;quot;JACTION_ADMIN&amp;quot; description=&amp;quot;JACTION_ADMIN_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.manage&amp;quot; title=&amp;quot;JACTION_MANAGE&amp;quot; description=&amp;quot;JACTION_MANAGE_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.create&amp;quot; title=&amp;quot;JACTION_CREATE&amp;quot; description=&amp;quot;JACTION_CREATE_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.delete&amp;quot; title=&amp;quot;JACTION_DELETE&amp;quot; description=&amp;quot;JACTION_DELETE_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.edit&amp;quot; title=&amp;quot;JACTION_EDIT&amp;quot; description=&amp;quot;JACTION_EDIT_COMPONENT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/section&amp;gt;&lt;br /&gt;
	&amp;lt;section name=&amp;quot;message&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.delete&amp;quot; title=&amp;quot;JACTION_DELETE&amp;quot; description=&amp;quot;COM_HELLOWORLD_ACCESS_DELETE_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;action name=&amp;quot;core.edit&amp;quot; title=&amp;quot;JACTION_EDIT&amp;quot; description=&amp;quot;COM_HELLOWORLD_ACCESS_EDIT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;/access&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Restricting access to the component ==&lt;br /&gt;
&lt;br /&gt;
The main idea in ACL is to restrict actions to groups of users. The first action that have to be restricted is the access to the component. With your favorite file editor, edit the &#039;&#039;admin/helloworld.php&#039;&#039; file and it these lines&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/helloworld.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/helloworld.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// Access check.&lt;br /&gt;
if (!JFactory::getUser()-&amp;gt;authorise(&#039;core.manage&#039;, &#039;com_helloworld&#039;)) &lt;br /&gt;
{&lt;br /&gt;
	return JError::raiseWarning(404, JText::_(&#039;JERROR_ALERTNOAUTHOR&#039;));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// require helper file&lt;br /&gt;
JLoader::register(&#039;HelloWorldHelper&#039;, dirname(__FILE__) . DS . &#039;helpers&#039; . DS . &#039;helloworld.php&#039;);&lt;br /&gt;
&lt;br /&gt;
// import joomla controller library&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
// Get an instance of the controller prefixed by HelloWorld&lt;br /&gt;
$controller = JController::getInstance(&#039;HelloWorld&#039;);&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute(JRequest::getCmd(&#039;task&#039;));&lt;br /&gt;
 &lt;br /&gt;
// Redirect if set by the controller&lt;br /&gt;
$controller-&amp;gt;redirect();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Displaying only the right toolbar buttons ==&lt;br /&gt;
&lt;br /&gt;
The toolbar buttons that have to displayed depends on the ACL rights.&lt;br /&gt;
&lt;br /&gt;
In the &#039;&#039;admin/views/helloworlds/view.html.php&#039;&#039;, put this code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/views/helloworlds/view.html.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/views/helloworlds/view.html.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// import Joomla view library&lt;br /&gt;
jimport(&#039;joomla.application.component.view&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * HelloWorlds View&lt;br /&gt;
 */&lt;br /&gt;
class HelloWorldViewHelloWorlds extends JView&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * HelloWorlds view display method&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	function display($tpl = null) &lt;br /&gt;
	{&lt;br /&gt;
		// Get data from the model&lt;br /&gt;
		$items = $this-&amp;gt;get(&#039;Items&#039;);&lt;br /&gt;
		$pagination = $this-&amp;gt;get(&#039;Pagination&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Check for errors.&lt;br /&gt;
		if (count($errors = $this-&amp;gt;get(&#039;Errors&#039;))) &lt;br /&gt;
		{&lt;br /&gt;
			JError::raiseError(500, implode(&#039;&amp;lt;br /&amp;gt;&#039;, $errors));&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		// Assign data to the view&lt;br /&gt;
		$this-&amp;gt;items = $items;&lt;br /&gt;
		$this-&amp;gt;pagination = $pagination;&lt;br /&gt;
&lt;br /&gt;
		// Set the toolbar&lt;br /&gt;
		$this-&amp;gt;addToolBar();&lt;br /&gt;
&lt;br /&gt;
		// Display the template&lt;br /&gt;
		parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
		// Set the document&lt;br /&gt;
		$this-&amp;gt;setDocument();&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Setting the toolbar&lt;br /&gt;
	 */&lt;br /&gt;
	protected function addToolBar() &lt;br /&gt;
	{&lt;br /&gt;
		$canDo = HelloWorldHelper::getActions();&lt;br /&gt;
		JToolBarHelper::title(JText::_(&#039;COM_HELLOWORLD_MANAGER_HELLOWORLDS&#039;), &#039;helloworld&#039;);&lt;br /&gt;
		if ($canDo-&amp;gt;get(&#039;core.create&#039;)) &lt;br /&gt;
		{&lt;br /&gt;
			JToolBarHelper::addNew(&#039;helloworld.add&#039;, &#039;JTOOLBAR_NEW&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		if ($canDo-&amp;gt;get(&#039;core.edit&#039;)) &lt;br /&gt;
		{&lt;br /&gt;
			JToolBarHelper::editList(&#039;helloworld.edit&#039;, &#039;JTOOLBAR_EDIT&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		if ($canDo-&amp;gt;get(&#039;core.delete&#039;)) &lt;br /&gt;
		{&lt;br /&gt;
			JToolBarHelper::deleteList(&#039;&#039;, &#039;helloworld.delete&#039;, &#039;JTOOLBAR_DELETE&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		if ($canDo-&amp;gt;get(&#039;core.admin&#039;)) &lt;br /&gt;
		{&lt;br /&gt;
			JToolBarHelper::divider();&lt;br /&gt;
			JToolBarHelper::preferences(&#039;com_helloworld&#039;);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to set up the document properties&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	protected function setDocument() &lt;br /&gt;
	{&lt;br /&gt;
		$document = JFactory::getDocument();&lt;br /&gt;
		$document-&amp;gt;setTitle(JText::_(&#039;COM_HELLOWORLD_ADMINISTRATION&#039;));&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;&#039;admin/views/helloworld/view.html.php&#039;&#039;, put this code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/views/helloworld/view.html.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/views/helloworld/view.html.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// import Joomla view library&lt;br /&gt;
jimport(&#039;joomla.application.component.view&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * HelloWorld View&lt;br /&gt;
 */&lt;br /&gt;
class HelloWorldViewHelloWorld extends JView&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * display method of Hello view&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	public function display($tpl = null) &lt;br /&gt;
	{&lt;br /&gt;
		// get the Data&lt;br /&gt;
		$form = $this-&amp;gt;get(&#039;Form&#039;);&lt;br /&gt;
		$item = $this-&amp;gt;get(&#039;Item&#039;);&lt;br /&gt;
		$script = $this-&amp;gt;get(&#039;Script&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Check for errors.&lt;br /&gt;
		if (count($errors = $this-&amp;gt;get(&#039;Errors&#039;))) &lt;br /&gt;
		{&lt;br /&gt;
			JError::raiseError(500, implode(&#039;&amp;lt;br /&amp;gt;&#039;, $errors));&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		// Assign the Data&lt;br /&gt;
		$this-&amp;gt;form = $form;&lt;br /&gt;
		$this-&amp;gt;item = $item;&lt;br /&gt;
		$this-&amp;gt;script = $script;&lt;br /&gt;
&lt;br /&gt;
		// Set the toolbar&lt;br /&gt;
		$this-&amp;gt;addToolBar();&lt;br /&gt;
&lt;br /&gt;
		// Display the template&lt;br /&gt;
		parent::display($tpl);&lt;br /&gt;
&lt;br /&gt;
		// Set the document&lt;br /&gt;
		$this-&amp;gt;setDocument();&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Setting the toolbar&lt;br /&gt;
	 */&lt;br /&gt;
	protected function addToolBar() &lt;br /&gt;
	{&lt;br /&gt;
		JRequest::setVar(&#039;hidemainmenu&#039;, true);&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
		$userId = $user-&amp;gt;id;&lt;br /&gt;
		$isNew = $this-&amp;gt;item-&amp;gt;id == 0;&lt;br /&gt;
		$canDo = HelloWorldHelper::getActions($this-&amp;gt;item-&amp;gt;id);&lt;br /&gt;
		JToolBarHelper::title($isNew ? JText::_(&#039;COM_HELLOWORLD_MANAGER_HELLOWORLD_NEW&#039;) : JText::_(&#039;COM_HELLOWORLD_MANAGER_HELLOWORLD_EDIT&#039;), &#039;helloworld&#039;);&lt;br /&gt;
		// Built the actions for new and existing records.&lt;br /&gt;
		if ($isNew) &lt;br /&gt;
		{&lt;br /&gt;
			// For new records, check the create permission.&lt;br /&gt;
			if ($canDo-&amp;gt;get(&#039;core.create&#039;)) &lt;br /&gt;
			{&lt;br /&gt;
				JToolBarHelper::apply(&#039;helloworld.apply&#039;, &#039;JTOOLBAR_APPLY&#039;);&lt;br /&gt;
				JToolBarHelper::save(&#039;helloworld.save&#039;, &#039;JTOOLBAR_SAVE&#039;);&lt;br /&gt;
				JToolBarHelper::custom(&#039;helloworld.save2new&#039;, &#039;save-new.png&#039;, &#039;save-new_f2.png&#039;, &#039;JTOOLBAR_SAVE_AND_NEW&#039;, false);&lt;br /&gt;
			}&lt;br /&gt;
			JToolBarHelper::cancel(&#039;helloworld.cancel&#039;, &#039;JTOOLBAR_CANCEL&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			if ($canDo-&amp;gt;get(&#039;core.edit&#039;))&lt;br /&gt;
			{&lt;br /&gt;
				// We can save the new record&lt;br /&gt;
				JToolBarHelper::apply(&#039;helloworld.apply&#039;, &#039;JTOOLBAR_APPLY&#039;);&lt;br /&gt;
				JToolBarHelper::save(&#039;helloworld.save&#039;, &#039;JTOOLBAR_SAVE&#039;);&lt;br /&gt;
&lt;br /&gt;
				// We can save this record, but check the create permission to see if we can return to make a new one.&lt;br /&gt;
				if ($canDo-&amp;gt;get(&#039;core.create&#039;)) &lt;br /&gt;
				{&lt;br /&gt;
					JToolBarHelper::custom(&#039;helloworld.save2new&#039;, &#039;save-new.png&#039;, &#039;save-new_f2.png&#039;, &#039;JTOOLBAR_SAVE_AND_NEW&#039;, false);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
			if ($canDo-&amp;gt;get(&#039;core.create&#039;)) &lt;br /&gt;
			{&lt;br /&gt;
				JToolBarHelper::custom(&#039;helloworld.save2copy&#039;, &#039;save-copy.png&#039;, &#039;save-copy_f2.png&#039;, &#039;JTOOLBAR_SAVE_AS_COPY&#039;, false);&lt;br /&gt;
			}&lt;br /&gt;
			JToolBarHelper::cancel(&#039;helloworld.cancel&#039;, &#039;JTOOLBAR_CLOSE&#039;);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to set up the document properties&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	protected function setDocument() &lt;br /&gt;
	{&lt;br /&gt;
		$isNew = $this-&amp;gt;item-&amp;gt;id == 0;&lt;br /&gt;
		$document = JFactory::getDocument();&lt;br /&gt;
		$document-&amp;gt;setTitle($isNew ? JText::_(&#039;COM_HELLOWORLD_HELLOWORLD_CREATING&#039;) : JText::_(&#039;COM_HELLOWORLD_HELLOWORLD_EDITING&#039;));&lt;br /&gt;
		$document-&amp;gt;addScript(JURI::root() . $this-&amp;gt;script);&lt;br /&gt;
		$document-&amp;gt;addScript(JURI::root() . &amp;quot;/administrator/components/com_helloworld/views/helloworld/submitbutton.js&amp;quot;);&lt;br /&gt;
		JText::script(&#039;COM_HELLOWORLD_HELLOWORLD_ERROR_UNACCEPTABLE&#039;);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These two files use the &#039;&#039;getActions&#039;&#039; method defined in the &#039;&#039;admin/helpers/helloworld.php&#039;&#039; file&lt;br /&gt;
&lt;br /&gt;
In the &#039;&#039;admin/helpers/helloworld.php&#039;&#039;, put this code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/helpers/helloworld.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/helpers/helloworld.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * HelloWorld component helper.&lt;br /&gt;
 */&lt;br /&gt;
abstract class HelloWorldHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Configure the Linkbar.&lt;br /&gt;
	 */&lt;br /&gt;
	public static function addSubmenu($submenu) &lt;br /&gt;
	{&lt;br /&gt;
		JSubMenuHelper::addEntry(JText::_(&#039;COM_HELLOWORLD_SUBMENU_MESSAGES&#039;), &#039;index.php?option=com_helloworld&#039;, $submenu == &#039;messages&#039;);&lt;br /&gt;
		JSubMenuHelper::addEntry(JText::_(&#039;COM_HELLOWORLD_SUBMENU_CATEGORIES&#039;), &#039;index.php?option=com_categories&amp;amp;view=categories&amp;amp;extension=com_helloworld&#039;, $submenu == &#039;categories&#039;);&lt;br /&gt;
		// set some global property&lt;br /&gt;
		$document = JFactory::getDocument();&lt;br /&gt;
		$document-&amp;gt;addStyleDeclaration(&#039;.icon-48-helloworld {background-image: url(../media/com_helloworld/images/tux-48x48.png);}&#039;);&lt;br /&gt;
		if ($submenu == &#039;categories&#039;) &lt;br /&gt;
		{&lt;br /&gt;
			$document-&amp;gt;setTitle(JText::_(&#039;COM_HELLOWORLD_ADMINISTRATION_CATEGORIES&#039;));&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get the actions&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getActions($messageId = 0)&lt;br /&gt;
	{&lt;br /&gt;
		$user	= JFactory::getUser();&lt;br /&gt;
		$result	= new JObject;&lt;br /&gt;
&lt;br /&gt;
		if (empty($messageId)) {&lt;br /&gt;
			$assetName = &#039;com_helloworld&#039;;&lt;br /&gt;
		}&lt;br /&gt;
		else {&lt;br /&gt;
			$assetName = &#039;com_helloworld.message.&#039;.(int) $messageId;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$actions = array(&lt;br /&gt;
			&#039;core.admin&#039;, &#039;core.manage&#039;, &#039;core.create&#039;, &#039;core.edit&#039;, &#039;core.delete&#039;&lt;br /&gt;
		);&lt;br /&gt;
&lt;br /&gt;
		foreach ($actions as $action) {&lt;br /&gt;
			$result-&amp;gt;set($action,	$user-&amp;gt;authorise($action, $assetName));&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Adding permissions settings in the component preferences ==&lt;br /&gt;
Since we now use ACL rights in our component, we need to set them at the component level.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/config.xml&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/config.xml&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;config&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset&lt;br /&gt;
		name=&amp;quot;greetings&amp;quot;&lt;br /&gt;
		label=&amp;quot;COM_HELLOWORLD_CONFIG_GREETING_SETTINGS_LABEL&amp;quot;&lt;br /&gt;
		description=&amp;quot;COM_HELLOWORLD_CONFIG_GREETING_SETTINGS_DESC&amp;quot;&lt;br /&gt;
	&amp;gt;&lt;br /&gt;
		&amp;lt;field&lt;br /&gt;
			name=&amp;quot;show_category&amp;quot;&lt;br /&gt;
			type=&amp;quot;radio&amp;quot;&lt;br /&gt;
			label=&amp;quot;COM_HELLOWORLD_HELLOWORLD_FIELD_SHOW_CATEGORY_LABEL&amp;quot;&lt;br /&gt;
			description=&amp;quot;COM_HELLOWORLD_HELLOWORLD_FIELD_SHOW_CATEGORY_DESC&amp;quot;&lt;br /&gt;
			default=&amp;quot;0&amp;quot;&lt;br /&gt;
		&amp;gt;&lt;br /&gt;
			&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JHIDE&amp;lt;/option&amp;gt;&lt;br /&gt;
			&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JSHOW&amp;lt;/option&amp;gt;&lt;br /&gt;
		&amp;lt;/field&amp;gt;&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset&lt;br /&gt;
		name=&amp;quot;permissions&amp;quot;&lt;br /&gt;
		label=&amp;quot;JCONFIG_PERMISSIONS_LABEL&amp;quot;&lt;br /&gt;
		description=&amp;quot;JCONFIG_PERMISSIONS_DESC&amp;quot;&lt;br /&gt;
	&amp;gt;&lt;br /&gt;
		&amp;lt;field&lt;br /&gt;
			name=&amp;quot;rules&amp;quot;&lt;br /&gt;
			type=&amp;quot;rules&amp;quot;&lt;br /&gt;
			label=&amp;quot;JCONFIG_PERMISSIONS_LABEL&amp;quot;&lt;br /&gt;
			class=&amp;quot;inputbox&amp;quot;&lt;br /&gt;
			validate=&amp;quot;rules&amp;quot;&lt;br /&gt;
			filter=&amp;quot;rules&amp;quot;&lt;br /&gt;
			component=&amp;quot;com_helloworld&amp;quot;&lt;br /&gt;
			section=&amp;quot;component&amp;quot;&lt;br /&gt;
		/&amp;gt;&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/config&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting the value in the assets table ==&lt;br /&gt;
&lt;br /&gt;
In order to set asset for each message, we have to do two things.&lt;br /&gt;
&lt;br /&gt;
First, we precise that the &#039;core.edit&#039; ACL right has to be taken from the message itself, then from the component&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/models/helloworld.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/models/helloworld.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// import Joomla modelform library&lt;br /&gt;
jimport(&#039;joomla.application.component.modeladmin&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * HelloWorld Model&lt;br /&gt;
 */&lt;br /&gt;
class HelloWorldModelHelloWorld extends JModelAdmin&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method override to check if you can edit an existing record.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param	array	$data	An array of input data.&lt;br /&gt;
	 * @param	string	$key	The name of the key for the primary key.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	boolean&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function allowEdit($data = array(), $key = &#039;id&#039;)&lt;br /&gt;
	{&lt;br /&gt;
		// Check specific edit permission then general edit permission.&lt;br /&gt;
		return JFactory::getUser()-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_helloworld.message.&#039;.((int) isset($data[$key]) ? $data[$key] : 0)) or parent::allowEdit($data, $key);&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Returns a reference to the a Table object, always creating it.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param	type	The table type to instantiate&lt;br /&gt;
	 * @param	string	A prefix for the table class name. Optional.&lt;br /&gt;
	 * @param	array	Configuration array for model. Optional.&lt;br /&gt;
	 * @return	JTable	A database object&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	public function getTable($type = &#039;HelloWorld&#039;, $prefix = &#039;HelloWorldTable&#039;, $config = array()) &lt;br /&gt;
	{&lt;br /&gt;
		return JTable::getInstance($type, $prefix, $config);&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to get the record form.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param	array	$data		Data for the form.&lt;br /&gt;
	 * @param	boolean	$loadData	True if the form is to load its own data (default case), false if not.&lt;br /&gt;
	 * @return	mixed	A JForm object on success, false on failure&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	public function getForm($data = array(), $loadData = true) &lt;br /&gt;
	{&lt;br /&gt;
		// Get the form.&lt;br /&gt;
		$form = $this-&amp;gt;loadForm(&#039;com_helloworld.helloworld&#039;, &#039;helloworld&#039;, array(&#039;control&#039; =&amp;gt; &#039;jform&#039;, &#039;load_data&#039; =&amp;gt; $loadData));&lt;br /&gt;
		if (empty($form)) &lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		return $form;&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to get the script that have to be included on the form&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return string	Script files&lt;br /&gt;
	 */&lt;br /&gt;
	public function getScript() &lt;br /&gt;
	{&lt;br /&gt;
		return &#039;administrator/components/com_helloworld/models/forms/helloworld.js&#039;;&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to get the data that should be injected in the form.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	mixed	The data for the form.&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function loadFormData() &lt;br /&gt;
	{&lt;br /&gt;
		// Check the session for previously entered form data.&lt;br /&gt;
		$data = JFactory::getApplication()-&amp;gt;getUserState(&#039;com_helloworld.edit.helloworld.data&#039;, array());&lt;br /&gt;
		if (empty($data)) &lt;br /&gt;
		{&lt;br /&gt;
			$data = $this-&amp;gt;getItem();&lt;br /&gt;
		}&lt;br /&gt;
		return $data;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Second, we precise the asset name, asset title and asset parent in the helloworld table&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/tables/helloworld.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/tables/helloworld.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// No direct access&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// import Joomla table library&lt;br /&gt;
jimport(&#039;joomla.database.table&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Hello Table class&lt;br /&gt;
 */&lt;br /&gt;
class HelloWorldTableHelloWorld extends JTable&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Constructor&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param object Database connector object&lt;br /&gt;
	 */&lt;br /&gt;
	function __construct(&amp;amp;$db) &lt;br /&gt;
	{&lt;br /&gt;
		parent::__construct(&#039;#__helloworld&#039;, &#039;id&#039;, $db);&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Overloaded bind function&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param       array           named array&lt;br /&gt;
	 * @return      null|string     null is operation was satisfactory, otherwise returns an error&lt;br /&gt;
	 * @see JTable:bind&lt;br /&gt;
	 * @since 1.5&lt;br /&gt;
	 */&lt;br /&gt;
	public function bind($array, $ignore = &#039;&#039;) &lt;br /&gt;
	{&lt;br /&gt;
		if (isset($array[&#039;params&#039;]) &amp;amp;&amp;amp; is_array($array[&#039;params&#039;])) &lt;br /&gt;
		{&lt;br /&gt;
			// Convert the params field to a string.&lt;br /&gt;
			$parameter = new JRegistry;&lt;br /&gt;
			$parameter-&amp;gt;loadArray($array[&#039;params&#039;]);&lt;br /&gt;
			$array[&#039;params&#039;] = (string)$parameter;&lt;br /&gt;
		}&lt;br /&gt;
		return parent::bind($array, $ignore);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Overloaded load function&lt;br /&gt;
	 *&lt;br /&gt;
	 * @param       int $pk primary key&lt;br /&gt;
	 * @param       boolean $reset reset data&lt;br /&gt;
	 * @return      boolean&lt;br /&gt;
	 * @see JTable:load&lt;br /&gt;
	 */&lt;br /&gt;
	public function load($pk = null, $reset = true) &lt;br /&gt;
	{&lt;br /&gt;
		if (parent::load($pk, $reset)) &lt;br /&gt;
		{&lt;br /&gt;
			// Convert the params field to a registry.&lt;br /&gt;
			$params = new JRegistry;&lt;br /&gt;
			$params-&amp;gt;loadJSON($this-&amp;gt;params);&lt;br /&gt;
			$this-&amp;gt;params = $params;&lt;br /&gt;
			return true;&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to compute the default name of the asset.&lt;br /&gt;
	 * The default name is in the form `table_name.id`&lt;br /&gt;
	 * where id is the value of the primary key of the table.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	string&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function _getAssetName()&lt;br /&gt;
	{&lt;br /&gt;
		$k = $this-&amp;gt;_tbl_key;&lt;br /&gt;
		return &#039;com_helloworld.message.&#039;.(int) $this-&amp;gt;$k;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to return the title to use for the asset table.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	string&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function _getAssetTitle()&lt;br /&gt;
	{&lt;br /&gt;
		return $this-&amp;gt;greeting;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get the parent asset id for the record&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	int&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function _getAssetParentId()&lt;br /&gt;
	{&lt;br /&gt;
		$asset = JTable::getInstance(&#039;Asset&#039;);&lt;br /&gt;
		$asset-&amp;gt;loadByName(&#039;com_helloworld&#039;);&lt;br /&gt;
		return $asset-&amp;gt;id;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Packaging the component ==&lt;br /&gt;
&lt;br /&gt;
Content of your code directory&lt;br /&gt;
* &#039;&#039;[[#helloworld.xml|helloworld.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_02#site/helloworld.php|site/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_02#site/controller.php|site/controller.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/views/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/views/helloworld/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#site/views/helloworld/view.html.php|site/views/helloworld/view.html.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/views/helloworld/tmpl/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_06#site/views/helloworld/tmpl/default.xml|site/views/helloworld/tmpl/default.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#site/views/helloworld/tmpl/default.php|site/views/helloworld/tmpl/default.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/models/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#site/models/helloworld.php|site/models/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/language/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/language/en-GB/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_08#site/language/en-GB/en-GB.com_helloworld.ini|site/language/en-GB/en-GB.com_helloworld.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/access.xml|admin/access.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/config.xml|admin/config.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/helloworld.php|admin/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_12#admin/controller.php|admin/controller.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/sql/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/sql/install.mysql.utf8.sql|admin/sql/install.mysql.utf8.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_06#admin/sql/uninstall.mysql.utf8.sql|admin/sql/uninstall.mysql.utf8.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/sql/updates/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/sql/updates/mysql/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#admin/sql/updates/mysql/0.0.1.sql|admin/sql/updates/mysql/0.0.1.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_06#admin/sql/install.mysql.utf8.sql|admin/sql/updates/mysql/0.0.6.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_12#admin/sql/updates/mysql/0.0.12.sql|admin/sql/updates/mysql/0.0.12.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/sql/updates/mysql/0.0.13.sql|admin/sql/updates/mysql/0.0.13.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/fields/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_12#admin/models/fields/helloworld.php|admin/models/fields/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/forms/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/models/forms/helloworld.xml|admin/models/forms/helloworld.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/models/forms/helloworld.js|admin/models/forms/helloworld.js]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/rules/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/models/rules/greeting.php|admin/models/rules/greeting.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/models/helloworld.php|admin/models/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_09#admin/models/helloworlds.php|admin/models/helloworlds.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworlds/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/views/helloworlds/view.html.php|admin/views/helloworlds/view.html.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworlds/tmpl/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/views/helloworlds/tmpl/default.php|admin/views/helloworlds/tmpl/default.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_07#admin/views/helloworlds/tmpl/default_head.php|admin/views/helloworlds/tmpl/default_head.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_07#admin/views/helloworlds/tmpl/default_body.php|admin/views/helloworlds/tmpl/default_body.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_07#admin/views/helloworlds/tmpl/default_foot.php|admin/views/helloworlds/tmpl/default_foot.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworld/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/views/helloworld/view.html.php|admin/views/helloworld/view.html.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/views/helloworld/submitbutton.js|admin/views/helloworld/submitbutton.js]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworld/tmpl/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/views/helloworld/tmpl/edit.php|admin/views/helloworld/tmpl/edit.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/helpers/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/helpers/helloworld.php|admin/helpers/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/tables/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/tables/helloworld.php|admin/tables/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/language/en-GB/en-GB.com_helloworld.ini|admin/language/en-GB/en-GB.com_helloworld.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_08#admin/language/en-GB/en-GB.com_helloworld.sys.ini|admin/language/en-GB/en-GB.com_helloworld.sys.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/controllers/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/controllers/helloworld.php|admin/controllers/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/controllers/helloworlds.php|admin/controllers/helloworlds.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_08#language/en-GB/en-GB.ini|language/en-GB/en-GB.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|media/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|media/images/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;media/images/tux-16x16.png&#039;&#039;&lt;br /&gt;
* &#039;&#039;media/images/tux-48x48.png&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create a compressed file of this directory or directly download the [http://joomlacode.org/gf/download/frsrelease/11394/58412/com_helloworld-1.6-part14.zip archive] and install it using the extension manager of Joomla!1.6. You can add a menu item of this component using the menu manager in the backend.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;helloworld.xml&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;helloworld.xml&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;component&amp;quot; version=&amp;quot;1.6.0&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;name&amp;gt;COM_HELLOWORLD&amp;lt;/name&amp;gt;&lt;br /&gt;
	&amp;lt;!-- The following elements are optional and free of formatting conttraints --&amp;gt;&lt;br /&gt;
	&amp;lt;creationDate&amp;gt;November 2009&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
	&amp;lt;author&amp;gt;John Doe&amp;lt;/author&amp;gt;&lt;br /&gt;
	&amp;lt;authorEmail&amp;gt;john.doe@example.org&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
	&amp;lt;authorUrl&amp;gt;http://www.example.org&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
	&amp;lt;copyright&amp;gt;Copyright Info&amp;lt;/copyright&amp;gt;&lt;br /&gt;
	&amp;lt;license&amp;gt;License Info&amp;lt;/license&amp;gt;&lt;br /&gt;
	&amp;lt;!--  The version string is recorded in the components table --&amp;gt;&lt;br /&gt;
	&amp;lt;version&amp;gt;0.0.14&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;!-- The description is optional and defaults to the name --&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;COM_HELLOWORLD_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;install&amp;gt; &amp;lt;!-- Runs on install --&amp;gt;&lt;br /&gt;
		&amp;lt;sql&amp;gt;&lt;br /&gt;
			&amp;lt;file driver=&amp;quot;mysql&amp;quot; charset=&amp;quot;utf8&amp;quot;&amp;gt;sql/install.mysql.utf8.sql&amp;lt;/file&amp;gt;&lt;br /&gt;
		&amp;lt;/sql&amp;gt;&lt;br /&gt;
	&amp;lt;/install&amp;gt;&lt;br /&gt;
	&amp;lt;uninstall&amp;gt; &amp;lt;!-- Runs on uninstall --&amp;gt;&lt;br /&gt;
		&amp;lt;sql&amp;gt;&lt;br /&gt;
			&amp;lt;file driver=&amp;quot;mysql&amp;quot; charset=&amp;quot;utf8&amp;quot;&amp;gt;sql/uninstall.mysql.utf8.sql&amp;lt;/file&amp;gt;&lt;br /&gt;
		&amp;lt;/sql&amp;gt;&lt;br /&gt;
	&amp;lt;/uninstall&amp;gt;&lt;br /&gt;
	&amp;lt;update&amp;gt; &amp;lt;!-- Runs on update; New in 1.6 --&amp;gt;&lt;br /&gt;
		&amp;lt;schemas&amp;gt;&lt;br /&gt;
			&amp;lt;schemapath type=&amp;quot;mysql&amp;quot;&amp;gt;sql/updates/mysql&amp;lt;/schemapath&amp;gt;&lt;br /&gt;
		&amp;lt;/schemas&amp;gt;&lt;br /&gt;
	&amp;lt;/update&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;!-- Site Main File Copy Section --&amp;gt;&lt;br /&gt;
	&amp;lt;!-- Note the folder attribute: This attribute describes the folder&lt;br /&gt;
		to copy FROM in the package to install therefore files copied&lt;br /&gt;
		in this section are copied from /site/ in the package --&amp;gt;&lt;br /&gt;
	&amp;lt;files folder=&amp;quot;site&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helloworld.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;controller.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;views&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;models&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;com_helloworld&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;administration&amp;gt;&lt;br /&gt;
		&amp;lt;!-- Administration Menu Section --&amp;gt;&lt;br /&gt;
		&amp;lt;menu img=&amp;quot;../media/com_helloworld/images/tux-16x16.png&amp;quot;&amp;gt;COM_HELLOWORLD_MENU&amp;lt;/menu&amp;gt;&lt;br /&gt;
		&amp;lt;!-- Administration Main File Copy Section --&amp;gt;&lt;br /&gt;
		&amp;lt;!-- Note the folder attribute: This attribute describes the folder&lt;br /&gt;
			to copy FROM in the package to install therefore files copied&lt;br /&gt;
			in this section are copied from /admin/ in the package --&amp;gt;&lt;br /&gt;
		&amp;lt;files folder=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;!-- Admin Main File Copy Section --&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;config.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;access.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;helloworld.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;controller.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;!-- SQL files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;sql&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- tables files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;tables&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- models files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;models&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- views files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;views&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- controllers files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;controllers&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- helpers files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;helpers&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;languages folder=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;language/en-GB/en-GB.com_helloworld.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
			&amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;language/en-GB/en-GB.com_helloworld.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
		&amp;lt;/languages&amp;gt;&lt;br /&gt;
	&amp;lt;/administration&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Navigate ==&lt;br /&gt;
&lt;br /&gt;
[[Developing a Model-View-Controller (MVC) Component for Joomla!1.6 - Part 13|Prev: Adding configuration]]&lt;br /&gt;
[[Developing a Model-View-Controller (MVC) Component for Joomla!1.6 - Part 15|Next: Adding an install/uninstall/update script file]]&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
*[[User:cdemko|Christophe Demko]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[category:Joomla! 1.6]]&lt;br /&gt;
[[category:Manual]]&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:Developing_a_MVC_Component/Adding_an_install-uninstall-update_script_file&amp;diff=36664</id>
		<title>Archived:Developing a MVC Component/Adding an install-uninstall-update script file</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:Developing_a_MVC_Component/Adding_an_install-uninstall-update_script_file&amp;diff=36664"/>
		<updated>2011-02-02T19:17:47Z</updated>

		<summary type="html">&lt;p&gt;Datashuttle: Removed the admin file reference to the script file.  The reference is in the &amp;lt;scriptfile&amp;gt; tag.  Was causing install problems.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial is for {{JVer|1.6}}&lt;br /&gt;
&lt;br /&gt;
== Articles in this series ==&lt;br /&gt;
{{Chunk:Developing a Model-View-Controller (MVC) Component for Joomla!1.6 - Contents}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This tutorial is part of the [[Developing a Model-View-Controller (MVC) Component for Joomla!1.6]] tutorial. You are encouraged to read the previous parts of the tutorial before reading this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating the extension script file ==&lt;br /&gt;
Installing, updating and uninstalling a component may require additional operations that cannot be achieved by the basic operations described in the main xml file. Joomla 1.6 offers a new approach to solve this problem. It consists in using a php script file containing a class using five methods:&lt;br /&gt;
* preflight which is executed before install and update&lt;br /&gt;
* install&lt;br /&gt;
* update&lt;br /&gt;
* uninstall&lt;br /&gt;
* postflight which is executed after install and update&lt;br /&gt;
&lt;br /&gt;
Writing an extension script consists in declaring an class whose name is &#039;&#039;com_&#039;&#039;&#039;ComponentName&#039;&#039;&#039;InstallerScript&#039;&#039; with these 5 methods.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;script.php&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;script.php&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// No direct access to this file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Script file of HelloWorld component&lt;br /&gt;
 */&lt;br /&gt;
class com_helloWorldInstallerScript&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * method to install the component&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	function install($parent) &lt;br /&gt;
	{&lt;br /&gt;
		// $parent is the class calling this method&lt;br /&gt;
		$parent-&amp;gt;getParent()-&amp;gt;setRedirectURL(&#039;index.php?option=com_helloworld&#039;);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * method to uninstall the component&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	function uninstall($parent) &lt;br /&gt;
	{&lt;br /&gt;
		// $parent is the class calling this method&lt;br /&gt;
		echo &#039;&amp;lt;p&amp;gt;&#039; . JText::_(&#039;COM_HELLOWORLD_UNINSTALL_TEXT&#039;) . &#039;&amp;lt;/p&amp;gt;&#039;;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * method to update the component&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	function update($parent) &lt;br /&gt;
	{&lt;br /&gt;
		// $parent is the class calling this method&lt;br /&gt;
		echo &#039;&amp;lt;p&amp;gt;&#039; . JText::_(&#039;COM_HELLOWORLD_UPDATE_TEXT&#039;) . &#039;&amp;lt;/p&amp;gt;&#039;;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * method to run before an install/update/uninstall method&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	function preflight($type, $parent) &lt;br /&gt;
	{&lt;br /&gt;
		// $parent is the class calling this method&lt;br /&gt;
		// $type is the type of change (install, update or discover_install)&lt;br /&gt;
		echo &#039;&amp;lt;p&amp;gt;&#039; . JText::_(&#039;COM_HELLOWORLD_PREFLIGHT_&#039; . $type . &#039;_TEXT&#039;) . &#039;&amp;lt;/p&amp;gt;&#039;;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * method to run after an install/update/uninstall method&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return void&lt;br /&gt;
	 */&lt;br /&gt;
	function postflight($type, $parent) &lt;br /&gt;
	{&lt;br /&gt;
		// $parent is the class calling this method&lt;br /&gt;
		// $type is the type of change (install, update or discover_install)&lt;br /&gt;
		echo &#039;&amp;lt;p&amp;gt;&#039; . JText::_(&#039;COM_HELLOWORLD_POSTFLIGHT_&#039; . $type . &#039;_TEXT&#039;) . &#039;&amp;lt;/p&amp;gt;&#039;;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script file will redirect the user to the com_helloworld component when it is installed and will display messages when it is updated or uninstalled.&lt;br /&gt;
&lt;br /&gt;
== Adding some language keys ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;admin/language/en-GB/en-GB.com_helloworld.sys.ini&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;admin/language/en-GB/en-GB.com_helloworld.sys.ini&amp;quot;&amp;quot;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
COM_HELLOWORLD=&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_DESCRIPTION=&amp;quot;This is the Hello World description&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_DESC=&amp;quot;This view displays a selected message&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_TITLE=&amp;quot;Hello World&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_INSTALL_TEXT=&amp;quot;HelloWorld Install script&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_MENU=&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_POSTFLIGHT_DISCOVER_INSTALL_TEXT=&amp;quot;HelloWorld postlight discover install script&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_POSTFLIGHT_INSTALL_TEXT=&amp;quot;HelloWorld postflight install script&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_POSTFLIGHT_UNINSTALL_TEXT=&amp;quot;HelloWorld postflight uninstall script&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_POSTFLIGHT_UPDATE_TEXT=&amp;quot;HelloWorld postflight update script&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_PREFLIGHT_DISCOVER_INSTALL_TEXT=&amp;quot;HelloWorld preflight discover install script&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_PREFLIGHT_INSTALL_TEXT=&amp;quot;HelloWorld preflight install script&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_PREFLIGHT_UNINSTALL_TEXT=&amp;quot;HelloWorld preflight uninstall script&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_PREFLIGHT_UPDATE_TEXT=&amp;quot;HelloWorld preflight update script&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_UNINSTALL_TEXT=&amp;quot;HelloWorld Uninstall script&amp;quot;&lt;br /&gt;
COM_HELLOWORLD_UPDATE_TEXT=&amp;quot;HelloWorld Update script&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Packaging the component ==&lt;br /&gt;
&lt;br /&gt;
Content of your code directory&lt;br /&gt;
* &#039;&#039;[[#helloworld.xml|helloworld.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#script.php|script.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_02#site/helloworld.php|site/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_02#site/controller.php|site/controller.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/views/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/views/helloworld/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#site/views/helloworld/view.html.php|site/views/helloworld/view.html.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/views/helloworld/tmpl/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_06#site/views/helloworld/tmpl/default.xml|site/views/helloworld/tmpl/default.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#site/views/helloworld/tmpl/default.php|site/views/helloworld/tmpl/default.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/models/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#site/models/helloworld.php|site/models/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/language/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|site/language/en-GB/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_08#site/language/en-GB/en-GB.com_helloworld.ini|site/language/en-GB/en-GB.com_helloworld.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_14#admin/access.xml|admin/access.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_14#admin/config.xml|admin/config.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_14#admin/helloworld.php|admin/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_12#admin/controller.php|admin/controller.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/sql/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/sql/install.mysql.utf8.sql|admin/sql/install.mysql.utf8.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_06#admin/sql/uninstall.mysql.utf8.sql|admin/sql/uninstall.mysql.utf8.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/sql/updates/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/sql/updates/mysql/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#admin/sql/updates/mysql/0.0.1.sql|admin/sql/updates/mysql/0.0.1.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_06#admin/sql/install.mysql.utf8.sql|admin/sql/updates/mysql/0.0.6.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_12#admin/sql/updates/mysql/0.0.12.sql|admin/sql/updates/mysql/0.0.12.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/sql/updates/mysql/0.0.13.sql|admin/sql/updates/mysql/0.0.13.sql]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/fields/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_12#admin/models/fields/helloworld.php|admin/models/fields/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/forms/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/models/forms/helloworld.xml|admin/models/forms/helloworld.xml]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/models/forms/helloworld.js|admin/models/forms/helloworld.js]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/models/rules/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/models/rules/greeting.php|admin/models/rules/greeting.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_14#admin/models/helloworld.php|admin/models/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_09#admin/models/helloworlds.php|admin/models/helloworlds.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworlds/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_14#admin/views/helloworlds/view.html.php|admin/views/helloworlds/view.html.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworlds/tmpl/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/views/helloworlds/tmpl/default.php|admin/views/helloworlds/tmpl/default.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_07#admin/views/helloworlds/tmpl/default_head.php|admin/views/helloworlds/tmpl/default_head.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_07#admin/views/helloworlds/tmpl/default_body.php|admin/views/helloworlds/tmpl/default_body.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_07#admin/views/helloworlds/tmpl/default_foot.php|admin/views/helloworlds/tmpl/default_foot.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworld/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_14#admin/views/helloworld/view.html.php|admin/views/helloworld/view.html.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/views/helloworld/submitbutton.js|admin/views/helloworld/submitbutton.js]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/views/helloworld/tmpl/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/views/helloworld/tmpl/edit.php|admin/views/helloworld/tmpl/edit.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/helpers/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_14#admin/helpers/helloworld.php|admin/helpers/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/tables/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_14#admin/tables/helloworld.php|admin/tables/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_13#admin/language/en-GB/en-GB.com_helloworld.ini|admin/language/en-GB/en-GB.com_helloworld.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[#admin/language/en-GB/en-GB.com_helloworld.sys.ini|admin/language/en-GB/en-GB.com_helloworld.sys.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|admin/controllers/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/controllers/helloworld.php|admin/controllers/helloworld.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_11#admin/controllers/helloworlds.php|admin/controllers/helloworlds.php]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_08#language/en-GB/en-GB.ini|language/en-GB/en-GB.ini]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|media/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;[[Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!1.6_-_Part_01#index.html|media/images/index.html]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;media/images/tux-16x16.png&#039;&#039;&lt;br /&gt;
* &#039;&#039;media/images/tux-48x48.png&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create a compressed file of this directory or directly download the [http://joomlacode.org/gf/download/frsrelease/11394/58461/com_helloworld-1.6-part15.zip archive] and install it using the extension manager of Joomla!1.6. You can add a menu item of this component using the menu manager in the backend.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;helloworld.xml&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;helloworld.xml&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;component&amp;quot; version=&amp;quot;1.6.0&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;name&amp;gt;COM_HELLOWORLD&amp;lt;/name&amp;gt;&lt;br /&gt;
	&amp;lt;!-- The following elements are optional and free of formatting conttraints --&amp;gt;&lt;br /&gt;
	&amp;lt;creationDate&amp;gt;November 2009&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
	&amp;lt;author&amp;gt;John Doe&amp;lt;/author&amp;gt;&lt;br /&gt;
	&amp;lt;authorEmail&amp;gt;john.doe@example.org&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
	&amp;lt;authorUrl&amp;gt;http://www.example.org&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
	&amp;lt;copyright&amp;gt;Copyright Info&amp;lt;/copyright&amp;gt;&lt;br /&gt;
	&amp;lt;license&amp;gt;License Info&amp;lt;/license&amp;gt;&lt;br /&gt;
	&amp;lt;!--  The version string is recorded in the components table --&amp;gt;&lt;br /&gt;
	&amp;lt;version&amp;gt;0.0.15&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;!-- The description is optional and defaults to the name --&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;COM_HELLOWORLD_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;!-- Runs on install/uninstall/update; New in 1.6 --&amp;gt;&lt;br /&gt;
	&amp;lt;scriptfile&amp;gt;script.php&amp;lt;/scriptfile&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;install&amp;gt; &amp;lt;!-- Runs on install --&amp;gt;&lt;br /&gt;
		&amp;lt;sql&amp;gt;&lt;br /&gt;
			&amp;lt;file driver=&amp;quot;mysql&amp;quot; charset=&amp;quot;utf8&amp;quot;&amp;gt;sql/install.mysql.utf8.sql&amp;lt;/file&amp;gt;&lt;br /&gt;
		&amp;lt;/sql&amp;gt;&lt;br /&gt;
	&amp;lt;/install&amp;gt;&lt;br /&gt;
	&amp;lt;uninstall&amp;gt; &amp;lt;!-- Runs on uninstall --&amp;gt;&lt;br /&gt;
		&amp;lt;sql&amp;gt;&lt;br /&gt;
			&amp;lt;file driver=&amp;quot;mysql&amp;quot; charset=&amp;quot;utf8&amp;quot;&amp;gt;sql/uninstall.mysql.utf8.sql&amp;lt;/file&amp;gt;&lt;br /&gt;
		&amp;lt;/sql&amp;gt;&lt;br /&gt;
	&amp;lt;/uninstall&amp;gt;&lt;br /&gt;
	&amp;lt;update&amp;gt; &amp;lt;!-- Runs on update; New in 1.6 --&amp;gt;&lt;br /&gt;
		&amp;lt;schemas&amp;gt;&lt;br /&gt;
			&amp;lt;schemapath type=&amp;quot;mysql&amp;quot;&amp;gt;sql/updates/mysql&amp;lt;/schemapath&amp;gt;&lt;br /&gt;
		&amp;lt;/schemas&amp;gt;&lt;br /&gt;
	&amp;lt;/update&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;!-- Site Main File Copy Section --&amp;gt;&lt;br /&gt;
	&amp;lt;!-- Note the folder attribute: This attribute describes the folder&lt;br /&gt;
		to copy FROM in the package to install therefore files copied&lt;br /&gt;
		in this section are copied from /site/ in the package --&amp;gt;&lt;br /&gt;
	&amp;lt;files folder=&amp;quot;site&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helloworld.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;controller.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;views&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;models&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;com_helloworld&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;administration&amp;gt;&lt;br /&gt;
		&amp;lt;!-- Administration Menu Section --&amp;gt;&lt;br /&gt;
		&amp;lt;menu img=&amp;quot;../media/com_helloworld/images/tux-16x16.png&amp;quot;&amp;gt;COM_HELLOWORLD_MENU&amp;lt;/menu&amp;gt;&lt;br /&gt;
		&amp;lt;!-- Administration Main File Copy Section --&amp;gt;&lt;br /&gt;
		&amp;lt;!-- Note the folder attribute: This attribute describes the folder&lt;br /&gt;
			to copy FROM in the package to install therefore files copied&lt;br /&gt;
			in this section are copied from /admin/ in the package --&amp;gt;&lt;br /&gt;
		&amp;lt;files folder=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;!-- Admin Main File Copy Section --&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;config.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;access.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;helloworld.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;filename&amp;gt;controller.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
			&amp;lt;!-- SQL files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;sql&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- tables files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;tables&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- models files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;models&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- views files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;views&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- controllers files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;controllers&amp;lt;/folder&amp;gt;&lt;br /&gt;
			&amp;lt;!-- helpers files section --&amp;gt;&lt;br /&gt;
			&amp;lt;folder&amp;gt;helpers&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;languages folder=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;language/en-GB/en-GB.com_helloworld.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
			&amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;language/en-GB/en-GB.com_helloworld.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
		&amp;lt;/languages&amp;gt;&lt;br /&gt;
	&amp;lt;/administration&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Navigate ==&lt;br /&gt;
&lt;br /&gt;
[[Developing a Model-View-Controller (MVC) Component for Joomla!1.6 - Part 14|Prev: Adding ACL]]&lt;br /&gt;
[[Developing a Model-View-Controller (MVC) Component for Joomla!1.6 - Part 16|Next: Using the language filter facility]]&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
*[[User:cdemko|Christophe Demko]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[category:Joomla! 1.6]]&lt;br /&gt;
[[category:Manual]]&lt;br /&gt;
&#039;&#039;&#039;Bold text&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Datashuttle</name></author>
	</entry>
</feed>