<?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=EivindJ</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=EivindJ"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/EivindJ"/>
	<updated>2026-08-27T12:20:08Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=27765</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=27765"/>
		<updated>2010-05-20T12:51:43Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: lacks a colon&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 this 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;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Absolute_Basics_of_How_a_Component_Functions&amp;diff=27760</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=27760"/>
		<updated>2010-05-20T12:17:46Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: .php, not .html ;)&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 this 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;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J1.5_talk:Changing_multi-column_article_order_in_section_and_category_blogs&amp;diff=13948</id>
		<title>J1.5 talk:Changing multi-column article order in section and category blogs</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J1.5_talk:Changing_multi-column_article_order_in_section_and_category_blogs&amp;diff=13948"/>
		<updated>2009-04-15T08:46:30Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I am new to this site, the solution described is exactly what I am after, the solution tells you to copy the attached file blog.txt, but where is it?&lt;br /&gt;
&lt;br /&gt;
Just follow the link. Also note that this is now built into 1.5.7, so that&#039;s the better way to go. [[User:Dextercowley|Mark Dexter]] 14:44, 2 October 2008 (EDT)&lt;br /&gt;
&lt;br /&gt;
==Article name==&lt;br /&gt;
Shouldn&#039;t it be &amp;quot;multi-column&amp;quot; and not &amp;quot;mutli-column&amp;quot;? --[[User:EivindJ|EivindJ]] 07:35, 15 April 2009 (UTC)&lt;br /&gt;
&lt;br /&gt;
Well spotted.  Fixed.  Thanks. [[User:Chris Davenport|Chris Davenport]] 08:35, 15 April 2009 (UTC)&lt;br /&gt;
&lt;br /&gt;
:Thank you! --[[User:EivindJ|EivindJ]] 08:46, 15 April 2009 (UTC)&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J1.5_talk:Changing_multi-column_article_order_in_section_and_category_blogs&amp;diff=13938</id>
		<title>J1.5 talk:Changing multi-column article order in section and category blogs</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J1.5_talk:Changing_multi-column_article_order_in_section_and_category_blogs&amp;diff=13938"/>
		<updated>2009-04-15T07:35:18Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I am new to this site, the solution described is exactly what I am after, the solution tells you to copy the attached file blog.txt, but where is it?&lt;br /&gt;
&lt;br /&gt;
Just follow the link. Also note that this is now built into 1.5.7, so that&#039;s the better way to go. [[User:Dextercowley|Mark Dexter]] 14:44, 2 October 2008 (EDT)&lt;br /&gt;
&lt;br /&gt;
==Article name==&lt;br /&gt;
Shouldn&#039;t it be &amp;quot;multi-column&amp;quot; and not &amp;quot;mutli-column&amp;quot;? --[[User:EivindJ|EivindJ]] 07:35, 15 April 2009 (UTC)&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Talk:Auto_Redirect_Guests_to_Login&amp;diff=13936</id>
		<title>Talk:Auto Redirect Guests to Login</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Talk:Auto_Redirect_Guests_to_Login&amp;diff=13936"/>
		<updated>2009-04-15T07:33:19Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Talk:Auto Redirect Guests to Login moved to Talk:Auto redirect guests to login: de facto naming convention&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Talk:Auto redirect guests to login]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Talk:Auto_redirect_guests_to_login&amp;diff=13935</id>
		<title>Talk:Auto redirect guests to login</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Talk:Auto_redirect_guests_to_login&amp;diff=13935"/>
		<updated>2009-04-15T07:33:19Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Talk:Auto Redirect Guests to Login moved to Talk:Auto redirect guests to login: de facto naming convention&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I&#039;m developing a component that I want to be visible to all but force the user to log in before using it.  I am using the following code in the default php file that my component runs upon loading.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;  &lt;br /&gt;
$user   = &amp;amp; JFactory::getUser();&lt;br /&gt;
  if ($user-&amp;gt;guest)&lt;br /&gt;
  {&lt;br /&gt;
    $forceLoginController = new JController;&lt;br /&gt;
    $forceLoginController-&amp;gt;setRedirect(&#039;index.php?option=com_user&amp;amp;view=login&#039;);&lt;br /&gt;
    $forceLoginController-&amp;gt;redirect();&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I&#039;m pretty much a Joomla! noob, but I don&#039;t see any reason why this shouldn&#039;t be used.&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Auto_Redirect_Guests_to_Login&amp;diff=13934</id>
		<title>Auto Redirect Guests to Login</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Auto_Redirect_Guests_to_Login&amp;diff=13934"/>
		<updated>2009-04-15T07:33:17Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Auto Redirect Guests to Login moved to Auto redirect guests to login: de facto naming convention&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Auto redirect guests to login]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Auto_redirect_guests_to_login&amp;diff=13933</id>
		<title>Auto redirect guests to login</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Auto_redirect_guests_to_login&amp;diff=13933"/>
		<updated>2009-04-15T07:33:17Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Auto Redirect Guests to Login moved to Auto redirect guests to login: de facto naming convention&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Desired Functionality===&lt;br /&gt;
Suppose you have some menu choices that require a user to be logged in, like &amp;quot;Submit an Article&amp;quot;. You would like all users to be able to see the restricted menu item, whether or not they are logged in.&lt;br /&gt;
&lt;br /&gt;
If the user is logged in, they just go directly to the restricted menu item.&lt;br /&gt;
&lt;br /&gt;
If the user is not logged in&lt;br /&gt;
*they are presented with the login form, and&lt;br /&gt;
*once they log in successfully, they continue on to the restricted page.&lt;br /&gt;
&lt;br /&gt;
If they are not registered, they have the option to register or navigate to another page.&lt;br /&gt;
&lt;br /&gt;
===Solution===&lt;br /&gt;
Here is how you do this in Joomla!.&lt;br /&gt;
&lt;br /&gt;
#Create a new menu from menu manager, say it is named &amp;quot;hidden menu&amp;quot;.&lt;br /&gt;
#Add any menu items that will be accessible only to registered users (for example, &amp;quot;Submit an Article&amp;quot;). Set the required access levels of these menu items (&amp;quot;Special&amp;quot; in this example, but it could also be &amp;quot;Registered&amp;quot;). &lt;br /&gt;
#Do NOT create a module for the &amp;quot;hidden menu&amp;quot;. It will not be displayed on any page, so it doesn&#039;t need a module.&lt;br /&gt;
#Create your &amp;quot;real&amp;quot; menu (for example, &amp;quot;main menu&amp;quot;) and the menu item that will display for all users (for example &amp;quot;Submit an Article&amp;quot;). &lt;br /&gt;
:*The menu item will have a menu item type of &amp;quot;Alias&amp;quot;.&lt;br /&gt;
:*It&#039;s &amp;quot;Menu Item&amp;quot; parameter will be the &amp;quot;Submit an Article&amp;quot; menu item on the &amp;quot;hidden menu&amp;quot;. &lt;br /&gt;
:*The Access Level for this menu item will be &amp;quot;Public&amp;quot;, since we want everyone to be able to see and use it.&lt;br /&gt;
#Create a module of type &amp;quot;mod_mainmenu&amp;quot; for this menu, just like you do for any menu.&lt;br /&gt;
#If you want sub-menus, make sure you&#039;ve added the sub-menu items in the &amp;quot;main menu&amp;quot; and not the &amp;quot;hidden menu&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now, when a guest (non-logged-in user) accesses the &amp;quot;Submit an Article&amp;quot; menu choice, it redirects them to the login page. If they log in successfully, they are taken to the desired page (in this case, &amp;quot;Submit an Article&amp;quot;). If there were already logged in, they go there directly.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
In my case, I&#039;ve added the following menu items:&lt;br /&gt;
1.HOME &lt;br /&gt;
2.BLOG (IDOBlog)&lt;br /&gt;
3.WIKI (A Wiki)&lt;br /&gt;
4.DIRECTORY (SOBI2)&lt;br /&gt;
5.CLASSIFIEDS (ads)&lt;br /&gt;
6.FAQS (Articles section)&lt;br /&gt;
7.SHOP (vitrue mart)&lt;br /&gt;
8.Contact US (contacts)&lt;br /&gt;
&lt;br /&gt;
I wanted that ALL the menu items are viewable by public (non-registered users included) at the front end. But I want that menu items 3,4,5,6 &amp;amp; 7 are accesible by REGISTERED users only. In other words if anyone clicks on menu item 3/4/5/6/7 they&#039;ll be lead to the login modules. &lt;br /&gt;
&lt;br /&gt;
So, I created a &amp;quot;hidden menu&amp;quot; with the menu items for 3 - 7, using the restricted access level. Then, when I created the &amp;quot;real&amp;quot; menu, I used the menu type &amp;quot;Alias&amp;quot; for these items and set the &amp;quot;Menu Item&amp;quot; Parameter to the corresponding menu item in the &amp;quot;hidden menu&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
As far as I know, this method is applicable to all menus in the menu manager. In case of any help or suggestion please contact me on forums.joomla.org my username is ziggy03. &lt;br /&gt;
In case of a better or alternate method please feel free to edit this page.&lt;br /&gt;
Thanks. &lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Adding_Access_Keys&amp;diff=13932</id>
		<title>Adding Access Keys</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Adding_Access_Keys&amp;diff=13932"/>
		<updated>2009-04-15T07:32:17Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Adding Access Keys moved to Adding access keys: de facto naming convention&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Adding access keys]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J1.5:Adding_access_keys&amp;diff=13931</id>
		<title>J1.5:Adding access keys</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J1.5:Adding_access_keys&amp;diff=13931"/>
		<updated>2009-04-15T07:32:17Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Adding Access Keys moved to Adding access keys: de facto naming convention&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Heres a quick way to add access keys to joomla 1.5. &#039;&#039;&#039;Note, This involves hacking the core code.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Firstly edit the component.xml parameter definiton file in \administrator\components\com_menus\models\metadata&lt;br /&gt;
and add to it an accesskey parameter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;param name=&amp;quot;accesskey&amp;quot; type=&amp;quot;text&amp;quot; size=&amp;quot;1&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;Accessibility Access Key&amp;quot;&lt;br /&gt;
description=&amp;quot;Accessibility Access Key for the page which this Menu item points to&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your file should now look something like:&lt;br /&gt;
&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;metadata&amp;gt;&lt;br /&gt;
       &amp;lt;state&amp;gt;&lt;br /&gt;
          &amp;lt;name&amp;gt;Component&amp;lt;/name&amp;gt;&lt;br /&gt;
          &amp;lt;description&amp;gt;Component Parameters&amp;lt;/description&amp;gt;&lt;br /&gt;
          &amp;lt;params&amp;gt;&lt;br /&gt;
             &amp;lt;param name=&amp;quot;page_title&amp;quot; type=&amp;quot;text&amp;quot; size=&amp;quot;30&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;Page Title&amp;quot;&lt;br /&gt;
               description=&amp;quot;PARAMPAGETITLE&amp;quot; /&amp;gt;&lt;br /&gt;
             &amp;lt;param name=&amp;quot;show_page_title&amp;quot; type=&amp;quot;radio&amp;quot; default=&amp;quot;1&amp;quot; label=&amp;quot;Show Page Title&amp;quot;&lt;br /&gt;
               description=&amp;quot;SHOW/HIDE THE PAGES TITLE&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;No&amp;lt;/option&amp;gt;&lt;br /&gt;
                &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;Yes&amp;lt;/option&amp;gt;&lt;br /&gt;
             &amp;lt;/param&amp;gt;&lt;br /&gt;
             &amp;lt;param name=&amp;quot;pageclass_sfx&amp;quot; type=&amp;quot;text&amp;quot; size=&amp;quot;20&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;Page Class Suffix&amp;quot;&lt;br /&gt;
               description=&amp;quot;PARAMPAGECLASSSFX&amp;quot; /&amp;gt;&lt;br /&gt;
             &amp;lt;param name=&amp;quot;@spacer&amp;quot; type=&amp;quot;spacer&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;&amp;quot; description=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
             &amp;lt;param name=&amp;quot;menu_image&amp;quot; type=&amp;quot;imagelist&amp;quot; directory=&amp;quot;/images/stories&amp;quot; hide_default=&amp;quot;1&amp;quot;&lt;br /&gt;
               default=&amp;quot;&amp;quot; label=&amp;quot;Menu Image&amp;quot; description=&amp;quot;PARAMMENUIMAGE&amp;quot; /&amp;gt;&lt;br /&gt;
             &amp;lt;param name=&amp;quot;@spacer&amp;quot; type=&amp;quot;spacer&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;&amp;quot; description=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
             &amp;lt;param name=&amp;quot;secure&amp;quot; type=&amp;quot;radio&amp;quot; default=&amp;quot;0&amp;quot; label=&amp;quot;SSL Enabled&amp;quot; description=&amp;quot;PARAMSECURE&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;option value=&amp;quot;-1&amp;quot;&amp;gt;Off&amp;lt;/option&amp;gt;&lt;br /&gt;
                &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;Ignore&amp;lt;/option&amp;gt;&lt;br /&gt;
                &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;On&amp;lt;/option&amp;gt;&lt;br /&gt;
             &amp;lt;/param&amp;gt;&lt;br /&gt;
             &amp;lt;param name=&amp;quot;@spacer&amp;quot; type=&amp;quot;spacer&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;&amp;quot; description=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
             &amp;lt;param name=&amp;quot;accesskey&amp;quot; type=&amp;quot;text&amp;quot; size=&amp;quot;1&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;Accessibility Access Key&amp;quot;&lt;br /&gt;
description=&amp;quot;Accessibility Access Key for the page which this Menu item points to&amp;quot; /&amp;gt;&lt;br /&gt;
          &amp;lt;/params&amp;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;
Now edit the frontend file \modules\mod_mainmenu\helper.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
    // ACCESS KEY HACK - Part 1&lt;br /&gt;
    $accessKey = $iParams-&amp;gt;get(&#039;accesskey&#039;);&lt;br /&gt;
    $tmp-&amp;gt;accessKey = $accessKey;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
    // ACCESS KEY HACK - Part 2&lt;br /&gt;
    if ($tmp-&amp;gt;accessKey)&lt;br /&gt;
    $data = &#039;&amp;lt;a href=&amp;quot;&#039;.$tmp-&amp;gt;url.&#039;&amp;quot; accesskey=&amp;quot;&#039;.$tmp-&amp;gt;accessKey.&#039;&amp;quot;&amp;gt;&#039;.$image.$tmp-&amp;gt;name.&#039;&amp;lt;/a&amp;gt;&#039;;&lt;br /&gt;
    else&lt;br /&gt;
    $data = &#039;&amp;lt;a href=&amp;quot;&#039;.$tmp-&amp;gt;url.&#039;&amp;quot; &amp;gt;&#039;.$image.$tmp-&amp;gt;name.&#039;&amp;lt;/a&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
into the _getItemData($item) function so that it looks like this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
    function _getItemData($item)&lt;br /&gt;
       {&lt;br /&gt;
          $data = null;&lt;br /&gt;
&lt;br /&gt;
          // Menu Link is a special type that is a link to another item&lt;br /&gt;
          if ($item-&amp;gt;type == &#039;menulink&#039;)&lt;br /&gt;
          {&lt;br /&gt;
             $menu = &amp;amp;JSite::getMenu();&lt;br /&gt;
             if ($tmp = clone($menu-&amp;gt;getItem($item-&amp;gt;query[&#039;Itemid&#039;]))) {&lt;br /&gt;
                $tmp-&amp;gt;name    = &#039;&amp;lt;span&amp;gt;&amp;lt;![CDATA[&#039;.$item-&amp;gt;name.&#039;]]&amp;gt;&amp;lt;/span&amp;gt;&#039;;&lt;br /&gt;
                $tmp-&amp;gt;mid    = $item-&amp;gt;id;&lt;br /&gt;
                $tmp-&amp;gt;parent = $item-&amp;gt;parent;&lt;br /&gt;
             } else {&lt;br /&gt;
                return false;&lt;br /&gt;
             }&lt;br /&gt;
          } else {&lt;br /&gt;
             $tmp = clone($item);&lt;br /&gt;
             $tmp-&amp;gt;name = &#039;&amp;lt;span&amp;gt;&amp;lt;![CDATA[&#039;.$item-&amp;gt;name.&#039;]]&amp;gt;&amp;lt;/span&amp;gt;&#039;;&lt;br /&gt;
          }&lt;br /&gt;
&lt;br /&gt;
          $iParams = new JParameter($tmp-&amp;gt;params);&lt;br /&gt;
          if ($iParams-&amp;gt;get(&#039;menu_image&#039;) &amp;amp;&amp;amp; $iParams-&amp;gt;get(&#039;menu_image&#039;) != -1) {&lt;br /&gt;
             $image = &#039;&amp;lt;img src=&amp;quot;&#039;.JURI::base(true).&#039;/images/stories/&#039;.$iParams-&amp;gt;get(&#039;menu_image&#039;).&#039;&amp;quot; alt=&amp;quot;&amp;quot; /&amp;gt;&#039;;&lt;br /&gt;
          } else {&lt;br /&gt;
             $image = null;&lt;br /&gt;
          }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          // ACCESS KEY HACK - Part 1&lt;br /&gt;
          $accessKey = $iParams-&amp;gt;get(&#039;accesskey&#039;);&lt;br /&gt;
          $tmp-&amp;gt;accessKey = $accessKey;&lt;br /&gt;
&lt;br /&gt;
          switch ($tmp-&amp;gt;type)&lt;br /&gt;
          {&lt;br /&gt;
             case &#039;separator&#039; :&lt;br /&gt;
                return &#039;&amp;lt;span class=&amp;quot;separator&amp;quot;&amp;gt;&#039;.$image.$tmp-&amp;gt;name.&#039;&amp;lt;/span&amp;gt;&#039;;&lt;br /&gt;
                break;&lt;br /&gt;
&lt;br /&gt;
             case &#039;url&#039; :&lt;br /&gt;
                if ((strpos($tmp-&amp;gt;link, &#039;index.php?&#039;) !== false) &amp;amp;&amp;amp; (strpos($tmp-&amp;gt;link, &#039;Itemid=&#039;) === false)) {&lt;br /&gt;
                   $tmp-&amp;gt;url = $tmp-&amp;gt;link.&#039;&amp;amp;amp;Itemid=&#039;.$tmp-&amp;gt;id;&lt;br /&gt;
                } else {&lt;br /&gt;
                   $tmp-&amp;gt;url = $tmp-&amp;gt;link;&lt;br /&gt;
                }&lt;br /&gt;
                break;&lt;br /&gt;
&lt;br /&gt;
             default :&lt;br /&gt;
                $router = JSite::getRouter();&lt;br /&gt;
                $tmp-&amp;gt;url = $router-&amp;gt;getMode() == JROUTER_MODE_SEF ?&lt;br /&gt;
                  &#039;index.php?Itemid=&#039;.$tmp-&amp;gt;id : $tmp-&amp;gt;link.&#039;&amp;amp;Itemid=&#039;.$tmp-&amp;gt;id;&lt;br /&gt;
                break;&lt;br /&gt;
          }&lt;br /&gt;
&lt;br /&gt;
          // Print a link if it exists&lt;br /&gt;
          if ($tmp-&amp;gt;url != null)&lt;br /&gt;
          {&lt;br /&gt;
             // Handle SSL links&lt;br /&gt;
             $iSecure = $iParams-&amp;gt;def(&#039;secure&#039;, 0);&lt;br /&gt;
             if ($tmp-&amp;gt;home == 1) {&lt;br /&gt;
                $tmp-&amp;gt;url = JURI::base();&lt;br /&gt;
             } elseif (strcasecmp(substr($tmp-&amp;gt;url, 0, 4), &#039;http&#039;) &amp;amp;&amp;amp; (strpos($tmp-&amp;gt;link, &#039;index.php?&#039;) !== false)) {&lt;br /&gt;
                $tmp-&amp;gt;url = JRoute::_($tmp-&amp;gt;url, true, $iSecure);&lt;br /&gt;
             } else {&lt;br /&gt;
                $tmp-&amp;gt;url = str_replace(&#039;&amp;amp;&#039;, &#039;&amp;amp;amp;&#039;, $tmp-&amp;gt;url);&lt;br /&gt;
             }&lt;br /&gt;
&lt;br /&gt;
             switch ($tmp-&amp;gt;browserNav)&lt;br /&gt;
             {&lt;br /&gt;
                default:&lt;br /&gt;
                case 0:&lt;br /&gt;
                   // _top&lt;br /&gt;
                   // ACCESS KEY HACK - Part 2          ###############################&lt;br /&gt;
                   if ($tmp-&amp;gt;accessKey)&lt;br /&gt;
                      $data = &#039;&amp;lt;a href=&amp;quot;&#039;.$tmp-&amp;gt;url.&#039;&amp;quot; accesskey=&amp;quot;&#039;.$tmp-&amp;gt;accessKey.&#039;&amp;quot;&amp;gt;&#039;.$image.$tmp-&amp;gt;name.&#039;&amp;lt;/a&amp;gt;&#039;;&lt;br /&gt;
                   else&lt;br /&gt;
                      $data = &#039;&amp;lt;a href=&amp;quot;&#039;.$tmp-&amp;gt;url.&#039;&amp;quot; &amp;gt;&#039;.$image.$tmp-&amp;gt;name.&#039;&amp;lt;/a&amp;gt;&#039;;&lt;br /&gt;
                   break;&lt;br /&gt;
                case 1:&lt;br /&gt;
                   // _blank&lt;br /&gt;
                   $data = &#039;&amp;lt;a href=&amp;quot;&#039;.$tmp-&amp;gt;url.&#039;&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&#039;.$image.$tmp-&amp;gt;name.&#039;&amp;lt;/a&amp;gt;&#039;;&lt;br /&gt;
                   break;&lt;br /&gt;
                case 2:&lt;br /&gt;
                   // window.open&lt;br /&gt;
                   $attribs = &#039;toolbar=no,location=no,status=no,menubar=no,&lt;br /&gt;
                     scrollbars=yes,resizable=yes,&#039;.$this-&amp;gt;_params-&amp;gt;get(&#039;window_open&#039;);&lt;br /&gt;
&lt;br /&gt;
                   // hrm...this is a bit dickey&lt;br /&gt;
                   $link = str_replace(&#039;index.php&#039;, &#039;index2.php&#039;, $tmp-&amp;gt;url);&lt;br /&gt;
                   $data = &#039;&amp;lt;a href=&amp;quot;&#039;.$link.&#039;&amp;quot; onclick=&amp;quot;window.open(this.href,\&#039;targetWindow\&#039;,\&#039;&#039;.$attribs.&#039;\&#039;);&lt;br /&gt;
                     return false;&amp;quot;&amp;gt;&#039;.$image.$tmp-&amp;gt;name.&#039;&amp;lt;/a&amp;gt;&#039;;&lt;br /&gt;
                   break;&lt;br /&gt;
             }&lt;br /&gt;
          } else {&lt;br /&gt;
             $data = &#039;&amp;lt;a&amp;gt;&#039;.$image.$tmp-&amp;gt;name.&#039;&amp;lt;/a&amp;gt;&#039;;&lt;br /&gt;
          }&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;
&lt;br /&gt;
Login to your admin site and edit a menu item. Now open the &amp;quot;Parameters - System&amp;quot; accordion item on the right and you will see your accesskey parameter. Set a value, save the menu item and voila.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;br /&gt;
[[Category:Tips and tricks 1.5]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_all_articles&amp;diff=13930</id>
		<title>Removing author name, creation date or update date from all articles</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_all_articles&amp;diff=13930"/>
		<updated>2009-04-15T07:31:32Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Settings for all Articles are referred to as &#039;&#039;&#039;Global Settings&#039;&#039;&#039; and the location for those settings has changed from 1.0 to 1.5.  The settings are now found in the Article Manager.&lt;br /&gt;
&lt;br /&gt;
To remove the author name, creation date and time and modified date and time from all Articles:&lt;br /&gt;
#Open the Article Manager.&lt;br /&gt;
#Click on the Parameters icon near the top right of your screen.&lt;br /&gt;
#Locate the Author Name, Created Date and Time and Modified Date and Time drop down fields in the Parameters list and change to Hide as required.&lt;br /&gt;
#*Hide: Hides the information globally.&lt;br /&gt;
#*Show: Displays the information globaly. &lt;br /&gt;
#Click the Save.&lt;br /&gt;
&lt;br /&gt;
These settings apply wherever &amp;quot;Use Global&amp;quot; is selected in the Article&#039;s parameters or menu item&#039;s parameters.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Removing author name, creation date or update date from an article]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_an_article&amp;diff=13929</id>
		<title>Removing author name, creation date or update date from an article</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_an_article&amp;diff=13929"/>
		<updated>2009-04-15T07:31:23Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To remove the author name, creation date and time and modified date and time from an Article:&lt;br /&gt;
#Open the Article for editing either by:&lt;br /&gt;
#* Click the &#039;&#039;&#039;Content &amp;gt; Article Manager&#039;&#039;&#039; menu item or click the &#039;&#039;Article Manager&#039;&#039; button in the Control Panel. &lt;br /&gt;
#* Once in the &#039;&#039;Article Manager&#039;&#039;, click the Article Title to edit or tick the box next to the Article and click the &#039;&#039;Edit&#039;&#039; button in the toolbar.&lt;br /&gt;
#* If you are logged in to the Front-end with appropriate permissions and are viewing the Article you wish to edit, click the &#039;&#039;Edit&#039;&#039; icon usually found at the upper right corner.&lt;br /&gt;
#Click on the &#039;&#039;Parameters - Advanced&#039;&#039; pane in the Parameters section of the Edit Article screen.&lt;br /&gt;
#Locate the &#039;&#039;Author Name&#039;&#039;, &#039;&#039;Created Date and Time&#039;&#039; and &#039;&#039;Modified Date and Time&#039;&#039; drop down fields in the Parameters list and change to &#039;&#039;Hide&#039;&#039; as required.&lt;br /&gt;
#*&#039;&#039;&#039;Use Global&#039;&#039;&#039;: Uses the setting in the Article Parameter Global configuration.&lt;br /&gt;
#*&#039;&#039;&#039;Hide&#039;&#039;&#039;: Hides the information and overwrites the global configuration for the current Article only.&lt;br /&gt;
#*&#039;&#039;&#039;Show&#039;&#039;&#039;: Displays the information and overwrites the global configuration for the current Article only.&lt;br /&gt;
#Click the &#039;&#039;Save&#039;&#039; or &#039;&#039;Apply&#039;&#039; button in the toolbar to save the Article.&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Removing author name, creation date or update date from all articles]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_an_Article&amp;diff=13928</id>
		<title>Removing author name, creation date or update date from an Article</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_an_Article&amp;diff=13928"/>
		<updated>2009-04-15T07:31:13Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Removing author name, creation date or update date from an Article moved to Removing author name, creation date or update date from an article: rm capital A&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Removing author name, creation date or update date from an article]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_an_article&amp;diff=13927</id>
		<title>Removing author name, creation date or update date from an article</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_an_article&amp;diff=13927"/>
		<updated>2009-04-15T07:31:13Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Removing author name, creation date or update date from an Article moved to Removing author name, creation date or update date from an article: rm capital A&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To remove the author name, creation date and time and modified date and time from an Article:&lt;br /&gt;
#Open the Article for editing either by:&lt;br /&gt;
#* Click the &#039;&#039;&#039;Content &amp;gt; Article Manager&#039;&#039;&#039; menu item or click the &#039;&#039;Article Manager&#039;&#039; button in the Control Panel. &lt;br /&gt;
#* Once in the &#039;&#039;Article Manager&#039;&#039;, click the Article Title to edit or tick the box next to the Article and click the &#039;&#039;Edit&#039;&#039; button in the toolbar.&lt;br /&gt;
#* If you are logged in to the Front-end with appropriate permissions and are viewing the Article you wish to edit, click the &#039;&#039;Edit&#039;&#039; icon usually found at the upper right corner.&lt;br /&gt;
#Click on the &#039;&#039;Parameters - Advanced&#039;&#039; pane in the Parameters section of the Edit Article screen.&lt;br /&gt;
#Locate the &#039;&#039;Author Name&#039;&#039;, &#039;&#039;Created Date and Time&#039;&#039; and &#039;&#039;Modified Date and Time&#039;&#039; drop down fields in the Parameters list and change to &#039;&#039;Hide&#039;&#039; as required.&lt;br /&gt;
#*&#039;&#039;&#039;Use Global&#039;&#039;&#039;: Uses the setting in the Article Parameter Global configuration.&lt;br /&gt;
#*&#039;&#039;&#039;Hide&#039;&#039;&#039;: Hides the information and overwrites the global configuration for the current Article only.&lt;br /&gt;
#*&#039;&#039;&#039;Show&#039;&#039;&#039;: Displays the information and overwrites the global configuration for the current Article only.&lt;br /&gt;
#Click the &#039;&#039;Save&#039;&#039; or &#039;&#039;Apply&#039;&#039; button in the toolbar to save the Article.&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Removing author name, creation date or update date from all Articles]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Talk:Removing_author_name,_creation_date_or_update_date_from_all_Articles&amp;diff=13926</id>
		<title>Talk:Removing author name, creation date or update date from all Articles</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Talk:Removing_author_name,_creation_date_or_update_date_from_all_Articles&amp;diff=13926"/>
		<updated>2009-04-15T07:30:53Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Talk:Removing author name, creation date or update date from all Articles moved to Talk:Removing author name, creation date or update date from all articles: rm capital A&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Talk:Removing author name, creation date or update date from all articles]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Talk:Removing_author_name,_creation_date_or_update_date_from_all_articles&amp;diff=13925</id>
		<title>Talk:Removing author name, creation date or update date from all articles</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Talk:Removing_author_name,_creation_date_or_update_date_from_all_articles&amp;diff=13925"/>
		<updated>2009-04-15T07:30:53Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Talk:Removing author name, creation date or update date from all Articles moved to Talk:Removing author name, creation date or update date from all articles: rm capital A&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In Joomla 1.5.9, I don&#039;t know why, but I have found that the global preference to hide author name, creation date and update, do not always work.  Perhaps they have to be set early, before articles are written?&lt;br /&gt;
&lt;br /&gt;
This certainly is the case with the Front Page.&lt;br /&gt;
&lt;br /&gt;
[[User:Lmacd|Lmacd]] 00:45, 3 March 2009 (UTC)&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_all_Articles&amp;diff=13924</id>
		<title>Removing author name, creation date or update date from all Articles</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_all_Articles&amp;diff=13924"/>
		<updated>2009-04-15T07:30:53Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Removing author name, creation date or update date from all Articles moved to Removing author name, creation date or update date from all articles: rm capital A&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Removing author name, creation date or update date from all articles]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_all_articles&amp;diff=13923</id>
		<title>Removing author name, creation date or update date from all articles</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_all_articles&amp;diff=13923"/>
		<updated>2009-04-15T07:30:53Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Removing author name, creation date or update date from all Articles moved to Removing author name, creation date or update date from all articles: rm capital A&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Settings for all Articles are referred to as &#039;&#039;&#039;Global Settings&#039;&#039;&#039; and the location for those settings has changed from 1.0 to 1.5.  The settings are now found in the Article Manager.&lt;br /&gt;
&lt;br /&gt;
To remove the author name, creation date and time and modified date and time from all Articles:&lt;br /&gt;
#Open the Article Manager.&lt;br /&gt;
#Click on the Parameters icon near the top right of your screen.&lt;br /&gt;
#Locate the Author Name, Created Date and Time and Modified Date and Time drop down fields in the Parameters list and change to Hide as required.&lt;br /&gt;
#*Hide: Hides the information globally.&lt;br /&gt;
#*Show: Displays the information globaly. &lt;br /&gt;
#Click the Save.&lt;br /&gt;
&lt;br /&gt;
These settings apply wherever &amp;quot;Use Global&amp;quot; is selected in the Article&#039;s parameters or menu item&#039;s parameters.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Removing author name, creation date or update date from an Article]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Why_does_my_site_get_messed_up_when_I_turn_on_SEF_(Search_Engine_Friendly_URLs)%3F&amp;diff=13922</id>
		<title>Why does my site get messed up when I turn on SEF (Search Engine Friendly URLs)?</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Why_does_my_site_get_messed_up_when_I_turn_on_SEF_(Search_Engine_Friendly_URLs)%3F&amp;diff=13922"/>
		<updated>2009-04-15T07:29:18Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: avoiding identical pages&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Why does your site get messed up when you turn on SEF (Search Engine Friendly URLs)?]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Why_can%27t_I_upload_files_using_the_flash_uploader%3F&amp;diff=13921</id>
		<title>Why can&#039;t I upload files using the flash uploader?</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Why_can%27t_I_upload_files_using_the_flash_uploader%3F&amp;diff=13921"/>
		<updated>2009-04-15T07:27:55Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Why can&amp;#039;t I upload files using the flash uploader? moved to Why can&amp;#039;t you upload files using the flash uploader?: de facto naming convention&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Why can&#039;t you upload files using the flash uploader?]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Why_can%27t_you_upload_files_using_the_flash_uploader%3F&amp;diff=13920</id>
		<title>Why can&#039;t you upload files using the flash uploader?</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Why_can%27t_you_upload_files_using_the_flash_uploader%3F&amp;diff=13920"/>
		<updated>2009-04-15T07:27:55Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Why can&amp;#039;t I upload files using the flash uploader? moved to Why can&amp;#039;t you upload files using the flash uploader?: de facto naming convention&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Sometimes the flash uploader does not work.&lt;br /&gt;
&lt;br /&gt;
# Check the write permissions for images/stories/ directories and subdirectories (Try to change permissions to 777)&lt;br /&gt;
# Check if your flash player version is upper to 7 (Update to newer version)&lt;br /&gt;
# If your PHP version was patched with suhosin (Add in your .htaccess, php.ini or suhosin.ini the next line: suhosin.session.encrypt = Off)&lt;br /&gt;
&lt;br /&gt;
If the problem persist you can deactivate the flash uploader in the Main Configuration Settings and use the traditional and safe form uploader.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
[[Category:Joomla! 1.5]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Why_can%27t_I_install_any_extensions%3F&amp;diff=13919</id>
		<title>Why can&#039;t I install any extensions?</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Why_can%27t_I_install_any_extensions%3F&amp;diff=13919"/>
		<updated>2009-04-15T07:27:30Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: avoiding identical pages&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Why can&#039;t you install any extensions?]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Why_can%27t_you_install_any_extensions%3F&amp;diff=13918</id>
		<title>Why can&#039;t you install any extensions?</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Why_can%27t_you_install_any_extensions%3F&amp;diff=13918"/>
		<updated>2009-04-15T07:27:01Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: some info from &amp;quot;Why can&amp;#039;t I install any extensions?&amp;quot; ... merging&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are several different issues that can cause this problem, depending on your Web hosting environment. &lt;br /&gt;
&lt;br /&gt;
=== PHP Version ===&lt;br /&gt;
&lt;br /&gt;
If your site is using PHP 5.0.4 this problem will occur. You need to ask your host to upgrade to a newer version of php. Joomla! does not work with PHP 5.0.4, there is no work around.&lt;br /&gt;
&lt;br /&gt;
=== Tmp and session paths ===&lt;br /&gt;
One common problem with remote hosts is that they sometimes move sites to different folders on the host server. In general, this does not cause obvious problems in Joomla!. However, when you install an extension, you need to be able to write to the &amp;quot;tmp&amp;quot; directory.&lt;br /&gt;
&lt;br /&gt;
In this case, you might get the error message: &amp;quot;JFolder::create: Could not create directory&amp;quot; and &amp;quot;Warning! Failed to move file.&amp;quot; If you have the Joomla! FTP layer enabled, you might get the message &amp;quot;JFTP::mkdir: Bad response, JFTP::chmod: Bad response, JFTP::store: Bad response, Warning! Failed to move file.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tmp directory:&#039;&#039;&#039; An incorrect tmp directory can cause this problem. To check this, look in your configuration.php file for the var $tmp_path value and make certain it matches your actual path. This must be writable to Joomla!.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Session path:&#039;&#039;&#039; The session.save_path directive in your php.ini file must be writable. To verify, use the [http://forum.joomla.org/viewtopic.php?f=428&amp;amp;t=272481 Forum Post Assistant]. If it reports &#039;&#039;save.session_path: Not Writable&#039;&#039; then there is a problem. Look at your php.ini directives and verify the location and the permissions of the session.save_path value. It must be a valid location and it must be writable for Joomla!. You may require the assistance of your Web host for this, depending on your Web hosting situation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== File ownership advice from ianmac ===&lt;br /&gt;
&lt;br /&gt;
At the heart of the issue is file ownership. There are generally two main server users that end up owning your files - the FTP user, and the Apache/PHP user. Obviously, when you upload files using FTP, the FTP user ends up owning them. Therefore, if you give a file 755 permissions, then ONLY the FTP user can write to that file.&lt;br /&gt;
&lt;br /&gt;
If you install Joomla! without the FTP layer, then the files it creates are owned by the Apache/PHP user. If you give the file 755 permissions, then ONLY the Apache/PHP user can write to that file.&lt;br /&gt;
&lt;br /&gt;
Just to emphasize, the fact that these username and passwords happen to be the same has no effect whatsoever on anything. They are different subsystems and are unrelated. It may be convenient, but will not solve your permission issues.&lt;br /&gt;
&lt;br /&gt;
So there are generally two approaches to take:&lt;br /&gt;
&lt;br /&gt;
# upload all the files via cpanel. This will generally result in all of the files being owned by the Apache/PHP user. Ensure that the root directory that all of your Joomla! files are installed in is writable, so that the installer can create the configuration.php file. Then, install Joomla! WITHOUT the FTP layer.&lt;br /&gt;
# upload all the files using FTP. This will generally result in all of the files being owned by the FTP user. Make sure that your Joomla! root directory is writable, again, so that the installer can create the configuration.php file. Then install Joomla! WITH the FTP layer.&lt;br /&gt;
&lt;br /&gt;
Ensure that your cache folders are owned by the Apache/PHP user, because these files are written by PHP. (cache because writing using the PHP user is much faster than via FTP.&lt;br /&gt;
&lt;br /&gt;
If you apply these principles - and choose either the first or the second approach, you should get better results and extension installation should work properly via the admin interface. Mixing the two approaches will cause you no end of grief.&lt;br /&gt;
&lt;br /&gt;
A good way to check that everything is in order is to browse to the Administrator section of your site and browse to Help-&amp;gt;System Info from the menu.  Click on directory permissions.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have the FTP layer enabled, it is important that everything show up as Writable.  If you do have the FTP layer enabled, then it is important that your two Cache directories show up as writable.  It is most likely okay that the rest show up as unwritable, because Joomla! can likely write these files using the stored FTP settings.  &lt;br /&gt;
&lt;br /&gt;
If you choose to use the FTP layer and you still have trouble, reupload the Joomla! 1.5 package onto your server using your FTP client and the FTP user that you specified in Joomla!&#039;s global configuration.  If your FTP client reports permission problems when trying to do this, contact your host for further assistance.&lt;br /&gt;
&lt;br /&gt;
==== Web hosting advice from HarryB ====&lt;br /&gt;
&lt;br /&gt;
There are some techniques used by some Web hosts that make this easier for novices. HarryB, longtime community member, has this advise for those of you who are not experts in security issues, and do not wish to invest time in that learning, and are considering finding a Web host environment that will allow you to avoid these scenarios:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;When looking for a host, ask if they implement phpsuexec and php-cgi. if they do, that&#039;s a good way to go as the ownership/permission issues in this environment will probably be far more manageable than they are when using the Apache php module (mod_php).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Empower yourself with knowledge and accept responsibility for your Web sites ====&lt;br /&gt;
&lt;br /&gt;
It is in your best interest to empower yourself with knowledge and facts and take full responsibility for your Web sites. Please, do not expect Joomla! forum volunteers to research your specific Web hosting situation and explain to you how to use environment. There are simply too many ways that hosting can be configured and too many Web sites for volunteers to do this for you. Work with your hosting environment. That is why you are paying them. Be respectful of this limitation, please, since it can be a real drain on volunteers. Forum volunteers are here to assist and cannot be expected to do your work or the work of your Web host for you.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
[[Category:Administration FAQ]]&lt;br /&gt;
[[Category:Getting Started FAQ]]&lt;br /&gt;
[[Category:Installation FAQ]]&lt;br /&gt;
[[Category:Upgrading and Migrating FAQ]]&lt;br /&gt;
[[Category:Version 1.5 FAQ]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Web_developers&amp;diff=13917</id>
		<title>Web developers</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Web_developers&amp;diff=13917"/>
		<updated>2009-04-15T07:19:20Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
{{Web developer profile}}&lt;br /&gt;
&lt;br /&gt;
==Joomla! Security Guide==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Security_Checklist|Joomla! Security Checklist]]&lt;br /&gt;
* [[Security and Performance FAQs]]&lt;br /&gt;
* [[Top 10 Stupidest Administrator Tricks]]&lt;br /&gt;
&lt;br /&gt;
;Joomla! Security Forums&lt;br /&gt;
&lt;br /&gt;
* [http://forum.joomla.org/viewforum.php?f=372 Joomla! Security Announcements]&lt;br /&gt;
* [http://forum.joomla.org/viewforum.php?f=432 Joomla! 1.5 Security Forum]&lt;br /&gt;
* [http://forum.joomla.org/viewforum.php?f=267 Joomla! 1.0 Security Forum]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Developers]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Category:Joomla!_versions&amp;diff=13916</id>
		<title>Category:Joomla! versions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Category:Joomla!_versions&amp;diff=13916"/>
		<updated>2009-04-15T07:16:55Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Top Level]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Category:Joomla!_versions&amp;diff=13915</id>
		<title>Category:Joomla! versions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Category:Joomla!_versions&amp;diff=13915"/>
		<updated>2009-04-15T07:16:34Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: New page: Category:Top level&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Top level]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Category:Joomla!_1.6&amp;diff=13914</id>
		<title>Category:Joomla! 1.6</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Category:Joomla!_1.6&amp;diff=13914"/>
		<updated>2009-04-15T07:16:23Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Category:Joomla! versions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{joomla version category}}&lt;br /&gt;
{{future|1.6}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Joomla! versions]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Category:Joomla!_1.5&amp;diff=13913</id>
		<title>Category:Joomla! 1.5</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Category:Joomla!_1.5&amp;diff=13913"/>
		<updated>2009-04-15T07:16:15Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Category:Joomla! versions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{joomla version category}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Joomla! versions]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Category:Joomla!_1.0&amp;diff=13912</id>
		<title>Category:Joomla! 1.0</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Category:Joomla!_1.0&amp;diff=13912"/>
		<updated>2009-04-15T07:16:08Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Category:Joomla! versions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{joomla version category}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Joomla! versions]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:Access_Control_System_In_Joomla_1.6&amp;diff=13911</id>
		<title>Archived:Access Control System In Joomla 1.6</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:Access_Control_System_In_Joomla_1.6&amp;diff=13911"/>
		<updated>2009-04-15T07:15:05Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: Category:Joomla! 1.6&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
===Sections===&lt;br /&gt;
Sections are used to group rules, actions for each extension using the table jos_access_sections&lt;br /&gt;
===Users===&lt;br /&gt;
These are users stored in jos_users table. Please note that gid and usertype fields are only there for legacy purposes and are not used in the current ACL system.&lt;br /&gt;
Users can be mapped to rules via jos_user_rule_map table.&lt;br /&gt;
in phpGACl, users were called AROs (Access Request Object)&lt;br /&gt;
===User Groups===&lt;br /&gt;
These are user groups that are hold in table jos_usergroups. You can have nested user groups. Each group obviously can hold an unlimited number of users and each user can be assigned to an unlimited number of user groups. These relations are hold in the table jos_user_usergroup_map.&lt;br /&gt;
User groups can be mapped to rules via jos_usergroup_rule_map table.&lt;br /&gt;
===Actions===&lt;br /&gt;
Actions are things your users will perform such that logging in to backend&lt;br /&gt;
===Assets===&lt;br /&gt;
Assets are items that you need to set access control on. For example each article on your site can be an asset and you can set edit permission for them. Currently these are not used in core.&lt;br /&gt;
===Asset Groups===&lt;br /&gt;
These are used for creating different view permissions for a combination of usergroups. (???)&lt;br /&gt;
How this is achieved:&lt;br /&gt;
* First a view action is created with access type 3. (eg. core.view)&lt;br /&gt;
* Then an asset group is created with some user groups in it.&lt;br /&gt;
* A rule is set with the name convention {action_name}.{asset_group_id} (eg. core.view.1 for Public)&lt;br /&gt;
* Both action, assetgroup and user groups are mapped to this rule.&lt;br /&gt;
*When three of them maps to the same rule JUser::getAuthorisedLevels() will also return the new asset group id.&lt;br /&gt;
===Rules===&lt;br /&gt;
Rules are combinations of actions and usergroups (or users) and optionally assets&lt;br /&gt;
There are three types of rules:&lt;br /&gt;
* Type 1: These are rules that allow a user or user group to do an action. For example user group X can log in to backend.&lt;br /&gt;
* Type 2: These are rules that allow a user or user group to do an action on an asset. For example user group X can edit an article with the id of Y.&lt;br /&gt;
* Type 3: These are rules that allow a user or user group to do an action (mostly view) on an asset group. For example user group X can view articles with the asset group of Y. (???)&lt;br /&gt;
==Library==&lt;br /&gt;
TODO&lt;br /&gt;
==Examples==&lt;br /&gt;
===Core Access Levels===&lt;br /&gt;
There are three access levels in core by default Public, Registered, Special. These are access levels. For them we use the action &#039;&#039;core.view&#039;&#039;. Let&#039;s use &#039;&#039;&#039;Special&#039;&#039;&#039; for our example:&lt;br /&gt;
First of all there is an asset group named Special. We need to tie some user groups to it and selecting Manager is enough. Because the system will automatically include its child groups (being Administrator and Super Administrator by default) The rule needed for this level is &#039;&#039;core.view.3&#039;&#039;. As you remember naming convention is action_name.asset_group_id and here our id is 3.&lt;br /&gt;
&lt;br /&gt;
[[Category:Joomla! 1.6]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_all_articles&amp;diff=13909</id>
		<title>Removing author name, creation date or update date from all articles</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_all_articles&amp;diff=13909"/>
		<updated>2009-04-15T07:12:12Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: cat + wikifying&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Settings for all Articles are referred to as &#039;&#039;&#039;Global Settings&#039;&#039;&#039; and the location for those settings has changed from 1.0 to 1.5.  The settings are now found in the Article Manager.&lt;br /&gt;
&lt;br /&gt;
To remove the author name, creation date and time and modified date and time from all Articles:&lt;br /&gt;
#Open the Article Manager.&lt;br /&gt;
#Click on the Parameters icon near the top right of your screen.&lt;br /&gt;
#Locate the Author Name, Created Date and Time and Modified Date and Time drop down fields in the Parameters list and change to Hide as required.&lt;br /&gt;
#*Hide: Hides the information globally.&lt;br /&gt;
#*Show: Displays the information globaly. &lt;br /&gt;
#Click the Save.&lt;br /&gt;
&lt;br /&gt;
These settings apply wherever &amp;quot;Use Global&amp;quot; is selected in the Article&#039;s parameters or menu item&#039;s parameters.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Removing author name, creation date or update date from an Article]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_an_article&amp;diff=13908</id>
		<title>Removing author name, creation date or update date from an article</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Removing_author_name,_creation_date_or_update_date_from_an_article&amp;diff=13908"/>
		<updated>2009-04-15T07:11:09Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: cat&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To remove the author name, creation date and time and modified date and time from an Article:&lt;br /&gt;
#Open the Article for editing either by:&lt;br /&gt;
#* Click the &#039;&#039;&#039;Content &amp;gt; Article Manager&#039;&#039;&#039; menu item or click the &#039;&#039;Article Manager&#039;&#039; button in the Control Panel. &lt;br /&gt;
#* Once in the &#039;&#039;Article Manager&#039;&#039;, click the Article Title to edit or tick the box next to the Article and click the &#039;&#039;Edit&#039;&#039; button in the toolbar.&lt;br /&gt;
#* If you are logged in to the Front-end with appropriate permissions and are viewing the Article you wish to edit, click the &#039;&#039;Edit&#039;&#039; icon usually found at the upper right corner.&lt;br /&gt;
#Click on the &#039;&#039;Parameters - Advanced&#039;&#039; pane in the Parameters section of the Edit Article screen.&lt;br /&gt;
#Locate the &#039;&#039;Author Name&#039;&#039;, &#039;&#039;Created Date and Time&#039;&#039; and &#039;&#039;Modified Date and Time&#039;&#039; drop down fields in the Parameters list and change to &#039;&#039;Hide&#039;&#039; as required.&lt;br /&gt;
#*&#039;&#039;&#039;Use Global&#039;&#039;&#039;: Uses the setting in the Article Parameter Global configuration.&lt;br /&gt;
#*&#039;&#039;&#039;Hide&#039;&#039;&#039;: Hides the information and overwrites the global configuration for the current Article only.&lt;br /&gt;
#*&#039;&#039;&#039;Show&#039;&#039;&#039;: Displays the information and overwrites the global configuration for the current Article only.&lt;br /&gt;
#Click the &#039;&#039;Save&#039;&#039; or &#039;&#039;Apply&#039;&#039; button in the toolbar to save the Article.&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Removing author name, creation date or update date from all Articles]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tips and tricks]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J1.5:Developing_a_MVC_Component/Creating_an_Administrator_Interface&amp;diff=13907</id>
		<title>J1.5:Developing a MVC Component/Creating an Administrator Interface</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J1.5:Developing_a_MVC_Component/Creating_an_Administrator_Interface&amp;diff=13907"/>
		<updated>2009-04-15T07:09:50Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: cat&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
In the first three tutorials, we have developed a MVC component that retrieves its data from a table in the database. Currently, there is no way to add data to the database except to do it manually using another tool. In this tutorial, we will develop an administrator section for our component which will make it possible to manage the entries in the database.&lt;br /&gt;
&lt;br /&gt;
== Creating the Basic Framework ==&lt;br /&gt;
&lt;br /&gt;
The basic framework of the administrator panel is very similar to the site portion. The main entry point for the administrator section of the component is hello.php. This file is identical to the hello.php file that was used in the site portion except the name of the controller it loads will be changed to HellosController. The default controller is also called controller.php and this file is identical to the default controller in the site portion, with the exception that the controller is named HellosController instead of HelloController. This difference is so that JController will by default load the hellos view, which will display a list of our greetings.&lt;br /&gt;
&lt;br /&gt;
Here is the listing for hello.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * @package    Joomla.Tutorials&lt;br /&gt;
 * @subpackage Components&lt;br /&gt;
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_4&lt;br /&gt;
 * @license    GNU/GPL&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
// No direct access&lt;br /&gt;
&lt;br /&gt;
defined( &#039;_JEXEC&#039; ) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
// Require the base controller&lt;br /&gt;
&lt;br /&gt;
require_once( JPATH_COMPONENT.DS.&#039;controller.php&#039; );&lt;br /&gt;
&lt;br /&gt;
// Require specific controller if requested&lt;br /&gt;
if($controller = JRequest::getWord(&#039;controller&#039;)) {&lt;br /&gt;
    $path = JPATH_COMPONENT.DS.&#039;controllers&#039;.DS.$controller.&#039;.php&#039;;&lt;br /&gt;
    if (file_exists($path)) {&lt;br /&gt;
        require_once $path;&lt;br /&gt;
    } else {&lt;br /&gt;
        $controller = &#039;&#039;;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Create the controller&lt;br /&gt;
$classname    = &#039;HellosController&#039;.$controller;&lt;br /&gt;
$controller   = new $classname( );&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute( JRequest::getVar( &#039;task&#039; ) );&lt;br /&gt;
&lt;br /&gt;
// Redirect if set by the controller&lt;br /&gt;
$controller-&amp;gt;redirect();&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The view and model that we will start with is the hellos view and the hellos model. We will start with the model.&lt;br /&gt;
&lt;br /&gt;
==== The Hellos Model ====&lt;br /&gt;
&lt;br /&gt;
The Hellos Model will be very simple. The only operation that we currently need is the ability to retrieve the list of hellos from the database. This operation will be implemented in a method called getData().&lt;br /&gt;
&lt;br /&gt;
The JModel class has a built in protected method called _getList(). This method can be used to simplify the task of retrieving a list of records from the database. We simply need to pass it the query and it will return the list of records.&lt;br /&gt;
&lt;br /&gt;
At a later point in time, we might want to use our query from within another method. Therefore, we will create a private method called _buildQuery() which will return the query that will be passed to _getList(). This makes it easier to change the query as well since it is localized in one place.&lt;br /&gt;
&lt;br /&gt;
Therefore we need two methods in our class: getData() and _buildQuery().&lt;br /&gt;
&lt;br /&gt;
_buildQuery() simply returns the query. It looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source  lang=&amp;quot;php&amp;quot;&amp;gt;/**&lt;br /&gt;
 * Returns the query&lt;br /&gt;
 * @return string The query to be used to retrieve the rows from the database&lt;br /&gt;
 */&lt;br /&gt;
function _buildQuery()&lt;br /&gt;
{&lt;br /&gt;
    $query = &#039; SELECT * &#039;&lt;br /&gt;
           . &#039; FROM #__hello &#039;&lt;br /&gt;
    ;&lt;br /&gt;
&lt;br /&gt;
    return $query;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
getData() will obtain the query and retrieve the records from the database. Now it might happen that we need to retrieve this list of data twice in one page load. It would be a waste to have to query the database twice. Therefore, we will have this method store the data in a protected property so that on subsequent requests it can simply return the data it has already retrieved. This property will be called _data.&lt;br /&gt;
&lt;br /&gt;
Here is the getData() method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source  lang=&amp;quot;php&amp;quot;&amp;gt;/**&lt;br /&gt;
 * Retrieves the hello data&lt;br /&gt;
 * @return array Array of objects containing the data from the database&lt;br /&gt;
 */&lt;br /&gt;
function getData()&lt;br /&gt;
{&lt;br /&gt;
    // Lets load the data if it doesn&#039;t already exist&lt;br /&gt;
    if (empty( $this-&amp;gt;_data ))&lt;br /&gt;
    {&lt;br /&gt;
        $query = $this-&amp;gt;_buildQuery();&lt;br /&gt;
        $this-&amp;gt;_data = $this-&amp;gt;_getList( $query );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return $this-&amp;gt;_data;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The completed model looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Hellos Model for Hello World Component&lt;br /&gt;
 * &lt;br /&gt;
 * @package    Joomla.Tutorials&lt;br /&gt;
 * @subpackage Components&lt;br /&gt;
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_4&lt;br /&gt;
 * @license        GNU/GPL&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Check to ensure this file is included in Joomla!&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die();&lt;br /&gt;
&lt;br /&gt;
jimport( &#039;joomla.application.component.model&#039; );&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Hello Model&lt;br /&gt;
 *&lt;br /&gt;
 * @package    Joomla.Tutorials&lt;br /&gt;
 * @subpackage Components&lt;br /&gt;
 */&lt;br /&gt;
class HellosModelHellos extends JModel&lt;br /&gt;
{&lt;br /&gt;
    /**&lt;br /&gt;
     * Hellos data array&lt;br /&gt;
     *&lt;br /&gt;
     * @var array&lt;br /&gt;
     */&lt;br /&gt;
    var $_data;&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns the query&lt;br /&gt;
     * @return string The query to be used to retrieve the rows from the database&lt;br /&gt;
     */&lt;br /&gt;
    function _buildQuery()&lt;br /&gt;
    {&lt;br /&gt;
        $query = &#039; SELECT * &#039;&lt;br /&gt;
            . &#039; FROM #__hello &#039;&lt;br /&gt;
        ;&lt;br /&gt;
        return $query;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Retrieves the hello data&lt;br /&gt;
     * @return array Array of objects containing the data from the database&lt;br /&gt;
     */&lt;br /&gt;
    function getData()&lt;br /&gt;
    {&lt;br /&gt;
        // Lets load the data if it doesn&#039;t already exist&lt;br /&gt;
        if (empty( $this-&amp;gt;_data ))&lt;br /&gt;
        {&lt;br /&gt;
            $query = $this-&amp;gt;_buildQuery();&lt;br /&gt;
            $this-&amp;gt;_data = $this-&amp;gt;_getList( $query );&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return $this-&amp;gt;_data;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file is saved as models/hellos.php.&lt;br /&gt;
&lt;br /&gt;
==== The Hellos View ====&lt;br /&gt;
&lt;br /&gt;
Now that we have a model to retrieve our data, we need to display it. This view will be fairly similar to the view from the site section as well.&lt;br /&gt;
&lt;br /&gt;
Just as our model was automatically instantiated in the site, so it is in the administrator. Methods that start with get in the model can be accessed using the get() method of the JView class. So our view has three lines: one to retrieve the data from the model, one to push the data into the template, and one to invoke the display method to display the output. Thus we have:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Hellos View for Hello World Component&lt;br /&gt;
 * &lt;br /&gt;
 * @package    Joomla.Tutorials&lt;br /&gt;
 * @subpackage Components&lt;br /&gt;
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_4&lt;br /&gt;
 * @license        GNU/GPL&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// Check to ensure this file is included in Joomla!&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die();&lt;br /&gt;
&lt;br /&gt;
jimport( &#039;joomla.application.component.view&#039; );&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Hellos View&lt;br /&gt;
 *&lt;br /&gt;
 * @package    Joomla.Tutorials&lt;br /&gt;
 * @subpackage Components&lt;br /&gt;
 */&lt;br /&gt;
class HellosViewHellos extends JView&lt;br /&gt;
{&lt;br /&gt;
    /**&lt;br /&gt;
     * Hellos view display method&lt;br /&gt;
     * @return void&lt;br /&gt;
     **/&lt;br /&gt;
    function display($tpl = null)&lt;br /&gt;
    {&lt;br /&gt;
        JToolBarHelper::title( JText::_( &#039;Hello Manager&#039; ), &#039;generic.png&#039; );&lt;br /&gt;
        JToolBarHelper::deleteList();&lt;br /&gt;
        JToolBarHelper::editListX();&lt;br /&gt;
        JToolBarHelper::addNewX();&lt;br /&gt;
&lt;br /&gt;
        // Get data from the model&lt;br /&gt;
        $items =&amp;amp; $this-&amp;gt;get( &#039;Data&#039;);&lt;br /&gt;
&lt;br /&gt;
        $this-&amp;gt;assignRef( &#039;items&#039;, $items );&lt;br /&gt;
&lt;br /&gt;
        parent::display($tpl);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file is saved as views/hellos/view.html.php.&lt;br /&gt;
&lt;br /&gt;
==== The Hellos Template ====&lt;br /&gt;
&lt;br /&gt;
The template will take the data pushed into it from the view and produce the output. We will display our output in a simple table. While the frontend template was very simple, in the administrator we will need a minimal amount of extra logic to handle looping through the data.&lt;br /&gt;
&lt;br /&gt;
Here is our template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;); ?&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;index.php&amp;quot; method=&amp;quot;post&amp;quot; name=&amp;quot;adminForm&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;editcell&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;table class=&amp;quot;adminlist&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;thead&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
            &amp;lt;th width=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;?php echo JText::_( &#039;ID&#039; ); ?&amp;gt;&lt;br /&gt;
            &amp;lt;/th&amp;gt;&lt;br /&gt;
            &amp;lt;th&amp;gt;&lt;br /&gt;
                &amp;lt;?php echo JText::_( &#039;Greeting&#039; ); ?&amp;gt;&lt;br /&gt;
            &amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt;            &lt;br /&gt;
    &amp;lt;/thead&amp;gt;&lt;br /&gt;
    &amp;lt;?php&lt;br /&gt;
    $k = 0;&lt;br /&gt;
    for ($i=0, $n=count( $this-&amp;gt;items ); $i &amp;lt; $n; $i++)&lt;br /&gt;
    {&lt;br /&gt;
        $row =&amp;amp; $this-&amp;gt;items[$i];&lt;br /&gt;
        ?&amp;gt;&lt;br /&gt;
        &amp;lt;tr class=&amp;quot;&amp;lt;?php echo &amp;quot;row$k&amp;quot;; ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&lt;br /&gt;
                &amp;lt;?php echo $row-&amp;gt;id; ?&amp;gt;&lt;br /&gt;
            &amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&lt;br /&gt;
                &amp;lt;?php echo $row-&amp;gt;greeting; ?&amp;gt;&lt;br /&gt;
            &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
        &amp;lt;?php&lt;br /&gt;
        $k = 1 - $k;&lt;br /&gt;
    }&lt;br /&gt;
    ?&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;option&amp;quot; value=&amp;quot;com_hello&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;task&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;boxchecked&amp;quot; value=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;controller&amp;quot; value=&amp;quot;hello&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/form&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This template is saved as views/hellos/tmpl/default.php.&lt;br /&gt;
&lt;br /&gt;
You will notice that our output is enclosed in a form. Though this is not necessary now, it will be soon.&lt;br /&gt;
&lt;br /&gt;
We have now completed the basic part of the first view. We have added five files to the admin section of our component:&lt;br /&gt;
&lt;br /&gt;
* hello.php&lt;br /&gt;
* controller.php&lt;br /&gt;
* models/hellos.php&lt;br /&gt;
* views/hellos/view.html.php&lt;br /&gt;
* views/hellos/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
You can now add these files to the XML install file and give it a try!&lt;br /&gt;
&lt;br /&gt;
== Adding Functionality ==&lt;br /&gt;
&lt;br /&gt;
So far our administrator section is pretty useless. It doesn&#039;t really do anything - all it does is display the entries that we have in our database.&lt;br /&gt;
&lt;br /&gt;
In order to make it useful, we need to add some buttons and links.&lt;br /&gt;
&lt;br /&gt;
==== The Toolbar ====&lt;br /&gt;
&lt;br /&gt;
You may have noticed the toolbar that appears at the top of other Joomla! component administrator panels. Our component needs one as well. Joomla! makes this very easy to do. We will add buttons Delete records, Edit records, and create New records. We will also add a title that will be displayed on our toolbar.&lt;br /&gt;
&lt;br /&gt;
This is done by adding code to the view. To add the buttons, we use static methods from the Joomla! JToolBarHelper class. The code looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;JToolBarHelper::title(   JText::_( &#039;Hello Manager&#039; ), &#039;generic.png&#039; );&lt;br /&gt;
JToolBarHelper::deleteList();&lt;br /&gt;
JToolBarHelper::editListX();&lt;br /&gt;
JToolBarHelper::addNewX();&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These three methods will create the appropriate buttons. The deleteList() method can optionally take up to three parameters - the first parameter is a string to display to the user to confirm that they want to delete the records. The second is the task that should be sent with the query (the default is &#039;remove&#039;), and the third is the text that should be displayed below the button.&lt;br /&gt;
&lt;br /&gt;
The editListX() and addNewX() methods can each take two optional parameters. The first is the task (which are by default edit and add, respectively), and the second is the text that should be displayed below the button.&lt;br /&gt;
&lt;br /&gt;
*You may have noticed the use of the JText::_ method in the template before and here as well. This is a handy function that makes component translation much easier. The JText::_ method will look up the string in your component language file and return the translated string. If no translation text is found, it will return the string that you passed to it. If you want to translate your component into another language, all you have to do is create a language file that will map the strings within the quotes to the translated version of the string.&lt;br /&gt;
&lt;br /&gt;
==== Checkboxes and Links ====&lt;br /&gt;
&lt;br /&gt;
We now have buttons. Two of those buttons operate on existing records. But how do we know which records to operate on? We have to let the user tell us. To do this, we need to add checkboxes to our table so that the user can select certain records. This is done in our template.&lt;br /&gt;
&lt;br /&gt;
In order to the add the checkboxes, we need to add an extra column into our table. We will add the column in between the two that we already have.&lt;br /&gt;
&lt;br /&gt;
In the header of the column, we will add a checkbox which can be used to toggle all the boxes below it on or off:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;th width=&amp;quot;20&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;toggle&amp;quot; value=&amp;quot;&amp;quot; onclick=&amp;quot;checkAll(&amp;lt;?php echo count( $this-&amp;gt;items ); ?&amp;gt;);&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/th&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Javascript checkAll function is a function that is built into the Joomla! base Javascript package that provides the functionality that we want here.&lt;br /&gt;
&lt;br /&gt;
Now we need to add the checkboxes into the individual rows. Joomla!&#039;s JHTML class has a method, JHTML::_(), which will generate our checkbox for us. We will add the following line to our loop:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;$checked    = JHTML::_( &#039;grid.id&#039;, $i, $row-&amp;gt;id );&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
after the line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;$row =&amp;amp; $this-&amp;gt;items[$i];&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we will add a cell in between the two that we already have:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;td&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $checked; ?&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It can be cumbersome to have to check the box that we want to edit and then move up and click the edit button. Therefore, we will add a link that it will go straight to the greeting&#039;s edit form. We will add the following line after the call to the JHTML::_() method to generate the link HTML:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;$link = JRoute::_( &#039;index.php?option=com_hello&amp;amp;controller=hello&amp;amp;task=edit&amp;amp;cid[]=&#039;. $row-&amp;gt;id );&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we include the link in the cell showing the greeting text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;td&amp;gt;&lt;br /&gt;
    &amp;lt;a href=&amp;quot;&amp;lt;?php echo $link; ?&amp;gt;&amp;quot;&amp;gt;&amp;lt;?php echo $row-&amp;gt;greeting; ?&amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will notice that this link points to the hello controller. This controller will handle the data manipulation of our greetings.&lt;br /&gt;
&lt;br /&gt;
If you recall from above, we had four hidden input fields at the bottom of our form. The first input field was named &#039;option&#039;. This field is necessary so that we stay in our component. The second input field was task. This form property gets set when one of the buttons in the toolbar is clicked. A Javascript error will result and the buttons will not work if this input field is omitted. The third input field is the boxchecked field. This field keeps track of the number of boxes that are checked. The edit and delete buttons will check to ensure that this is greater than zero and will not allow the form to be submitted if it is not. The fourth input field is the controller field. This is used to specify that tasks fired from this form will be handled by the hello controller.&lt;br /&gt;
&lt;br /&gt;
Here is the code for the completed default.php file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;); ?&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;index.php&amp;quot; method=&amp;quot;post&amp;quot; name=&amp;quot;adminForm&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;editcell&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;table class=&amp;quot;adminlist&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;thead&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
            &amp;lt;th width=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;?php echo JText::_( &#039;ID&#039; ); ?&amp;gt;&lt;br /&gt;
            &amp;lt;/th&amp;gt;&lt;br /&gt;
            &amp;lt;th width=&amp;quot;20&amp;quot;&amp;gt;&lt;br /&gt;
              &amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;toggle&amp;quot; value=&amp;quot;&amp;quot; onclick=&amp;quot;checkAll(&amp;lt;?php echo count( $this-&amp;gt;items ); ?&amp;gt;);&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;/th&amp;gt;&lt;br /&gt;
            &amp;lt;th&amp;gt;&lt;br /&gt;
                &amp;lt;?php echo JText::_( &#039;Greeting&#039; ); ?&amp;gt;&lt;br /&gt;
            &amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt;            &lt;br /&gt;
    &amp;lt;/thead&amp;gt;&lt;br /&gt;
    &amp;lt;?php&lt;br /&gt;
    $k = 0;&lt;br /&gt;
    for ($i=0, $n=count( $this-&amp;gt;items ); $i &amp;lt; $n; $i++)&lt;br /&gt;
    {&lt;br /&gt;
        $row =&amp;amp; $this-&amp;gt;items[$i];&lt;br /&gt;
        $checked    = JHTML::_( &#039;grid.id&#039;, $i, $row-&amp;gt;id );&lt;br /&gt;
        $link = JRoute::_( &#039;index.php?option=com_hello&amp;amp;controller=hello&amp;amp;task=edit&amp;amp;cid[]=&#039;. $row-&amp;gt;id );&lt;br /&gt;
        &lt;br /&gt;
        ?&amp;gt;&lt;br /&gt;
        &amp;lt;tr class=&amp;quot;&amp;lt;?php echo &amp;quot;row$k&amp;quot;; ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&lt;br /&gt;
                &amp;lt;?php echo $row-&amp;gt;id; ?&amp;gt;&lt;br /&gt;
            &amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&lt;br /&gt;
              &amp;lt;?php echo $checked; ?&amp;gt;&lt;br /&gt;
            &amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&lt;br /&gt;
                &amp;lt;a href=&amp;quot;&amp;lt;?php echo $link; ?&amp;gt;&amp;quot;&amp;gt;&amp;lt;?php echo $row-&amp;gt;greeting; ?&amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;
            &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
        &amp;lt;?php&lt;br /&gt;
        $k = 1 - $k;&lt;br /&gt;
    }&lt;br /&gt;
    ?&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;option&amp;quot; value=&amp;quot;com_hello&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;task&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;boxchecked&amp;quot; value=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;controller&amp;quot; value=&amp;quot;hello&amp;quot; /&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/form&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our hellos view is now complete.&lt;br /&gt;
&lt;br /&gt;
== Getting Down and Dirty: Doing the Real Work ==&lt;br /&gt;
&lt;br /&gt;
Now that the Hellos view is done, it is time to move to the Hello view and model. This is where the real work will get done.&lt;br /&gt;
&lt;br /&gt;
==== The Hello Controller ====&lt;br /&gt;
&lt;br /&gt;
Our default controller just isn&#039;t going to cut it when it comes to doing work - all it is capable of doing is displaying views.&lt;br /&gt;
&lt;br /&gt;
We need to be able to handle the tasks that we are launching from the Hellos view: add, edit and remove.&lt;br /&gt;
&lt;br /&gt;
Add and edit are essentially the same task: they both display a form to the user that allows a greeting to be edited. The only difference is that new displays a blank form, and edit displays a form with data already in it. Since they are similar, we will map the add task onto the edit task handler. This is specified in our constructor:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;/**&lt;br /&gt;
 * constructor (registers additional tasks to methods)&lt;br /&gt;
 * @return void&lt;br /&gt;
 */&lt;br /&gt;
function __construct()&lt;br /&gt;
{&lt;br /&gt;
    parent::__construct();&lt;br /&gt;
&lt;br /&gt;
    // Register Extra tasks&lt;br /&gt;
    $this-&amp;gt;registerTask( &#039;add&#039;  ,     &#039;edit&#039; );&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first parameter of JController::registerTask is the task to map, and the second is the method to map it to.&lt;br /&gt;
&lt;br /&gt;
We will start with handling the edit task. The controller&#039;s job is fairly simple for the edit task. All it has to do is specify the view and layout to load (the hello view and the form layout). We will also tell Joomla! to disable the mainmenu while we are editing our greeting. This prevents users from leaving unsaved records open.&lt;br /&gt;
&lt;br /&gt;
Our edit task handler looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;/**&lt;br /&gt;
 * display the edit form&lt;br /&gt;
 * @return void&lt;br /&gt;
 */&lt;br /&gt;
function edit()&lt;br /&gt;
{&lt;br /&gt;
    JRequest::setVar( &#039;view&#039;, &#039;hello&#039; );&lt;br /&gt;
    JRequest::setVar( &#039;layout&#039;, &#039;form&#039;  );&lt;br /&gt;
    JRequest::setVar(&#039;hidemainmenu&#039;, 1);&lt;br /&gt;
&lt;br /&gt;
    parent::display();&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== The Hello View ====&lt;br /&gt;
&lt;br /&gt;
The Hello view will display a form which will allow the user to edit a greeting. The display method if the hello view has to do a few simple tasks:&lt;br /&gt;
&lt;br /&gt;
* retrieve the data from the model&lt;br /&gt;
* create the toolbar&lt;br /&gt;
* pass the data into the template&lt;br /&gt;
* invoke the display() method to render the template&lt;br /&gt;
&lt;br /&gt;
This becomes a bit more complicated because the one view handles both the edit and add tasks. In our toolbar we want the user to know what whether they are adding or editing, so we have to determine which task was fired.&lt;br /&gt;
&lt;br /&gt;
Since we are already retrieving the record that we want to display from the model, we can use this data to determine what task was fired. If the task was edit, then the id field of our record will have been set. If the task was new, then it will not have been set. This can be used to determine if we have a new record or an existing record.&lt;br /&gt;
&lt;br /&gt;
We will add two buttons to the toolbar: save and cancel. Though the functionality will be the same, we want to display different buttons depending on whether it is a new or existing record. If it is a new record, we will display cancel. If it already exists, we will display close.&lt;br /&gt;
&lt;br /&gt;
Thus our display method looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;/**&lt;br /&gt;
 * display method of Hello view&lt;br /&gt;
 * @return void&lt;br /&gt;
 **/&lt;br /&gt;
function display($tpl = null)&lt;br /&gt;
{&lt;br /&gt;
    //get the hello&lt;br /&gt;
    $hello        =&amp;amp; $this-&amp;gt;get(&#039;Data&#039;);&lt;br /&gt;
    $isNew        = ($hello-&amp;gt;id &amp;lt; 1);&lt;br /&gt;
&lt;br /&gt;
    $text = $isNew ? JText::_( &#039;New&#039; ) : JText::_( &#039;Edit&#039; );&lt;br /&gt;
    JToolBarHelper::title(   JText::_( &#039;Hello&#039; ).&#039;: &amp;lt;small&amp;gt;&amp;lt;small&amp;gt;[ &#039; . $text.&#039; ]&amp;lt;/small&amp;gt;&amp;lt;/small&amp;gt;&#039; );&lt;br /&gt;
    JToolBarHelper::save();&lt;br /&gt;
    if ($isNew)  {&lt;br /&gt;
        JToolBarHelper::cancel();&lt;br /&gt;
    } else {&lt;br /&gt;
        // for existing items the button is renamed `close`&lt;br /&gt;
        JToolBarHelper::cancel( &#039;cancel&#039;, &#039;Close&#039; );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    $this-&amp;gt;assignRef(&#039;hello&#039;, $hello);&lt;br /&gt;
    parent::display($tpl);&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== The Hello Model ====&lt;br /&gt;
&lt;br /&gt;
Our view needs data. Therefore, we need to create a model to model a hello.&lt;br /&gt;
&lt;br /&gt;
Our model will have two properties: _id and _data. _id will hold the id of the greeting and data will hold the data.&lt;br /&gt;
&lt;br /&gt;
We will start with a constructor, which will attempt to retrieve the id from the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;/**&lt;br /&gt;
 * Constructor that retrieves the ID from the request&lt;br /&gt;
 *&lt;br /&gt;
 * @access    public&lt;br /&gt;
 * @return    void&lt;br /&gt;
 */&lt;br /&gt;
function __construct()&lt;br /&gt;
{&lt;br /&gt;
    parent::__construct();&lt;br /&gt;
&lt;br /&gt;
    $array = JRequest::getVar(&#039;cid&#039;,  0, &#039;&#039;, &#039;array&#039;);&lt;br /&gt;
    $this-&amp;gt;setId((int)$array[0]);&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The JRequest::getVar() method is used to retrieve data from the request. The first parameter is the name of the form variable. The second parameter is the default value to assign if there is no value found. The third parameter is the name of the hash to retrieve the value from (get, post, etc), and the last value is the data type that should be forced on the value.&lt;br /&gt;
&lt;br /&gt;
Our constructor will take the first value from the cid array and assign it to the id.&lt;br /&gt;
&lt;br /&gt;
Our setId() method can be used to set our id. Changing the id that our model points to will mean the id points to the wrong data. Therefore, when we set the id, we will clear the data property:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;/**&lt;br /&gt;
 * Method to set the hello identifier&lt;br /&gt;
 *&lt;br /&gt;
 * @access    public&lt;br /&gt;
 * @param    int Hello identifier&lt;br /&gt;
 * @return    void&lt;br /&gt;
 */&lt;br /&gt;
function setId($id)&lt;br /&gt;
{&lt;br /&gt;
    // Set id and wipe data&lt;br /&gt;
    $this-&amp;gt;_id        = $id;&lt;br /&gt;
    $this-&amp;gt;_data    = null;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we need a method to retrieve our data: getData()&lt;br /&gt;
&lt;br /&gt;
getData will check if the _data property has already been set. If it has, it will simply return it. Otherwise, it will load the data from the database.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;/**&lt;br /&gt;
 * Method to get a hello&lt;br /&gt;
 * @return object with data&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
function &amp;amp;getData()&lt;br /&gt;
{&lt;br /&gt;
    // Load the data&lt;br /&gt;
    if (empty( $this-&amp;gt;_data )) {&lt;br /&gt;
        $query = &#039; SELECT * FROM #__hello &#039;.&lt;br /&gt;
                &#039;  WHERE id = &#039;.$this-&amp;gt;_id;&lt;br /&gt;
        $this-&amp;gt;_db-&amp;gt;setQuery( $query );&lt;br /&gt;
        $this-&amp;gt;_data = $this-&amp;gt;_db-&amp;gt;loadObject();&lt;br /&gt;
    }&lt;br /&gt;
    if (!$this-&amp;gt;_data) {&lt;br /&gt;
        $this-&amp;gt;_data = new stdClass();&lt;br /&gt;
        $this-&amp;gt;_data-&amp;gt;id = 0;&lt;br /&gt;
        $this-&amp;gt;_data-&amp;gt;greeting = null;&lt;br /&gt;
    }&lt;br /&gt;
    return $this-&amp;gt;_data;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== The Form ====&lt;br /&gt;
&lt;br /&gt;
Now all that is left is to create the form that the data will go into. Since we specified our layout as form, the form will go in a file in the tmpl directory of the hello view called form.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;); ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;form action=&amp;quot;index.php&amp;quot; method=&amp;quot;post&amp;quot; name=&amp;quot;adminForm&amp;quot; id=&amp;quot;adminForm&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;col100&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;fieldset class=&amp;quot;adminform&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;legend&amp;gt;&amp;lt;?php echo JText::_( &#039;Details&#039; ); ?&amp;gt;&amp;lt;/legend&amp;gt;&lt;br /&gt;
        &amp;lt;table class=&amp;quot;admintable&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
            &amp;lt;td width=&amp;quot;100&amp;quot; align=&amp;quot;right&amp;quot; class=&amp;quot;key&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;label for=&amp;quot;greeting&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;?php echo JText::_( &#039;Greeting&#039; ); ?&amp;gt;:&lt;br /&gt;
                &amp;lt;/label&amp;gt;&lt;br /&gt;
            &amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&lt;br /&gt;
                &amp;lt;input class=&amp;quot;text_area&amp;quot; type=&amp;quot;text&amp;quot; name=&amp;quot;greeting&amp;quot; id=&amp;quot;greeting&amp;quot; size=&amp;quot;32&amp;quot; maxlength=&amp;quot;250&amp;quot; value=&amp;quot;&amp;lt;?php echo $this-&amp;gt;hello-&amp;gt;greeting;?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt;&lt;br /&gt;
    &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;clr&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;option&amp;quot; value=&amp;quot;com_hello&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;id&amp;quot; value=&amp;quot;&amp;lt;?php echo $this-&amp;gt;hello-&amp;gt;id; ?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;task&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;controller&amp;quot; value=&amp;quot;hello&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that in addition to the input field, there is a hidden field for the id. The user doesn&#039;t need to edit the id (and shouldn&#039;t), so we silently pass it along in the form.&lt;br /&gt;
&lt;br /&gt;
==== Implementing the Functionality ====&lt;br /&gt;
&lt;br /&gt;
So far, our controller only handles two tasks: edit and new. However, we also have buttons to save, delete and cancel records. We need to write code to handle and perform these tasks.&lt;br /&gt;
&lt;br /&gt;
=== Saving a Record ===&lt;br /&gt;
&lt;br /&gt;
The logical next step is to implement the functionality to save a record. Normally, this would require some switches and logic to handle various cases, such as the difference between creating a new record (an INSERT query), and updating an existing query (an UPDATE query). Also, there are complexities involved in getting the data from the form and putting it into the query.&lt;br /&gt;
&lt;br /&gt;
The Joomla! framework takes care of a lot of this for you. The JTable class makes it easy to manipulate records in the database without having to worry about writing the SQL code that lies behind these updates. It also makes it easy to transfer data from an HTML form into the database.&lt;br /&gt;
&lt;br /&gt;
== Creating the Table Class ==&lt;br /&gt;
&lt;br /&gt;
The JTable class is an abstract class from which you can derive child classes to work with specific tables. To use it, you simply create a class that extends the JTable class, add your database fields as properties, and override the constructor to specify the name of the table and the primary key.&lt;br /&gt;
&lt;br /&gt;
Here is our JTable class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Hello World table class&lt;br /&gt;
 * &lt;br /&gt;
 * @package    Joomla.Tutorials&lt;br /&gt;
 * @subpackage Components&lt;br /&gt;
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_4&lt;br /&gt;
 * @license        GNU/GPL&lt;br /&gt;
 */&lt;br /&gt;
&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;
/**&lt;br /&gt;
 * Hello Table class&lt;br /&gt;
 *&lt;br /&gt;
 * @package    Joomla.Tutorials&lt;br /&gt;
 * @subpackage Components&lt;br /&gt;
 */&lt;br /&gt;
class TableHello extends JTable&lt;br /&gt;
{&lt;br /&gt;
    /**&lt;br /&gt;
     * Primary Key&lt;br /&gt;
     *&lt;br /&gt;
     * @var int&lt;br /&gt;
     */&lt;br /&gt;
    var $id = null;&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * @var string&lt;br /&gt;
     */&lt;br /&gt;
    var $greeting = null;&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 TableHello( &amp;amp;$db ) {&lt;br /&gt;
        parent::__construct(&#039;#__hello&#039;, &#039;id&#039;, $db);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see here that we have defined our two fields: the id field and the greeting field. Then we have defined a constructor, which will call the constructor of the parent class and pass it the name of the table (hello), the name of the field which is the primary key (id), and the database connector object.&lt;br /&gt;
&lt;br /&gt;
This file should be called hello.php and it will go in a directory called tables in the administrator section of our component.&lt;br /&gt;
&lt;br /&gt;
== Implementing the Function in our Model ==&lt;br /&gt;
&lt;br /&gt;
We are now ready to add the method to the model which will save our record. We will call this method store. Our store() method will do three things: bind the data from the form to the TableHello object, check to ensure that the record is properly formed, and store the record in the database.&lt;br /&gt;
&lt;br /&gt;
Our method looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;/**&lt;br /&gt;
 * Method to store a record&lt;br /&gt;
 *&lt;br /&gt;
 * @access    public&lt;br /&gt;
 * @return    boolean    True on success&lt;br /&gt;
 */&lt;br /&gt;
function store()&lt;br /&gt;
{&lt;br /&gt;
    $row =&amp;amp; $this-&amp;gt;getTable();&lt;br /&gt;
&lt;br /&gt;
    $data = JRequest::get( &#039;post&#039; );&lt;br /&gt;
    // Bind the form fields to the hello table&lt;br /&gt;
    if (!$row-&amp;gt;bind($data)) {&lt;br /&gt;
        $this-&amp;gt;setError($this-&amp;gt;_db-&amp;gt;getErrorMsg());&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Make sure the hello record is valid&lt;br /&gt;
    if (!$row-&amp;gt;check()) {&lt;br /&gt;
        $this-&amp;gt;setError($this-&amp;gt;_db-&amp;gt;getErrorMsg());&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Store the web link table to the database&lt;br /&gt;
    if (!$row-&amp;gt;store()) {&lt;br /&gt;
        $this-&amp;gt;setError($this-&amp;gt;_db-&amp;gt;getErrorMsg());&lt;br /&gt;
        return false;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method gets added to the hello model.&lt;br /&gt;
&lt;br /&gt;
The method takes one parameter, which is an associative array of data that we want to store in the database. This can easily be retrieved from the request as will be seen later.&lt;br /&gt;
&lt;br /&gt;
You will see that the first line retrieves a reference to our JTable object. If we name our table properly, we don&#039;t have to specify its name - the JModel class knows where to find it. You may recall that we called our table class TableHello and put it in a file called hello.php in the tables directory. If you follow this convention, the JModel class can create your object automatically.&lt;br /&gt;
&lt;br /&gt;
The second line will retrieve the data from the form. The JRequest class makes this very easy. In this case, we are retrieving all of the variables that were submitted using the &#039;POST&#039; method. These will be returned as an associative array.&lt;br /&gt;
&lt;br /&gt;
The rest is easy - we bind, check and store. The bind() method will copy values from the array into the corresponding property of the table object. In this case, it will take the values of id and greeting and copy them to our TableHello object.&lt;br /&gt;
&lt;br /&gt;
The check() method will perform data verification. In the JTable() class, this method simply returns true. While this doesn&#039;t provide any value for us currently, by calling this method we make it possible to do data checking using our TableHello class in the future. This method can be overridden in our TableHello class with a method that performs the appropriate checks.&lt;br /&gt;
&lt;br /&gt;
The store() method will take the data that is in the object and store it in the database. If the id is 0, it will create a new record (INSERT), otherwise, it will update the existing record (UPDATE).&lt;br /&gt;
&lt;br /&gt;
== Adding the Task to the Controller ==&lt;br /&gt;
&lt;br /&gt;
We are now ready to add our task to the controller. Since the task that we are firing is called &#039;save&#039;, we must call our method &#039;save&#039;. This is simple:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;/**&lt;br /&gt;
 * save a record (and redirect to main page)&lt;br /&gt;
 * @return void&lt;br /&gt;
 */&lt;br /&gt;
function save()&lt;br /&gt;
{&lt;br /&gt;
    $model = $this-&amp;gt;getModel(&#039;hello&#039;);&lt;br /&gt;
&lt;br /&gt;
    if ($model-&amp;gt;store()) {&lt;br /&gt;
        $msg = JText::_( &#039;Greeting Saved!&#039; );&lt;br /&gt;
    } else {&lt;br /&gt;
        $msg = JText::_( &#039;Error Saving Greeting&#039; );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Check the table in so it can be edited.... we are done with it anyway&lt;br /&gt;
    $link = &#039;index.php?option=com_hello&#039;;&lt;br /&gt;
    $this-&amp;gt;setRedirect($link, $msg);&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All we do is get our model and invoke the store() method. Then we use the setRedirect() method to redirect back to our list of greetings. We also pass a message along, which will be displayed at the top of the page.&lt;br /&gt;
&lt;br /&gt;
=== Deleting a Record ===&lt;br /&gt;
&lt;br /&gt;
=== Implementing the Function in the Model ===&lt;br /&gt;
&lt;br /&gt;
In the model, we will retrieve the list of IDs to delete and call the JTable class to delete them. Here it is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;/**&lt;br /&gt;
 * Method to delete record(s)&lt;br /&gt;
 *&lt;br /&gt;
 * @access    public&lt;br /&gt;
 * @return    boolean    True on success&lt;br /&gt;
 */&lt;br /&gt;
function delete()&lt;br /&gt;
{&lt;br /&gt;
    $cids = JRequest::getVar( &#039;cid&#039;, array(0), &#039;post&#039;, &#039;array&#039; );&lt;br /&gt;
    $row =&amp;amp; $this-&amp;gt;getTable();&lt;br /&gt;
&lt;br /&gt;
    foreach($cids as $cid) {&lt;br /&gt;
        if (!$row-&amp;gt;delete( $cid )) {&lt;br /&gt;
            $this-&amp;gt;setError( $row-&amp;gt;getErrorMsg() );&lt;br /&gt;
            return false;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We invoke the JRequest::getVar() method to get the data from the request, then we invoke the $row-&amp;gt;delete() method to delete each row. By storing errors in the model we make it possible to retrieve them later if we so choose.&lt;br /&gt;
&lt;br /&gt;
=== Handling the Remove Task in the Controller ===&lt;br /&gt;
&lt;br /&gt;
This is similar to the save() method which handled the save task:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;/**&lt;br /&gt;
 * remove record(s)&lt;br /&gt;
 * @return void&lt;br /&gt;
 */&lt;br /&gt;
function remove()&lt;br /&gt;
{&lt;br /&gt;
    $model = $this-&amp;gt;getModel(&#039;hello&#039;);&lt;br /&gt;
    if(!$model-&amp;gt;delete()) {&lt;br /&gt;
        $msg = JText::_( &#039;Error: One or More Greetings Could not be Deleted&#039; );&lt;br /&gt;
    } else {&lt;br /&gt;
        $msg = JText::_( &#039;Greeting(s) Deleted&#039; );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    $this-&amp;gt;setRedirect( &#039;index.php?option=com_hello&#039;, $msg );&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cancelling the Edit Operation ====&lt;br /&gt;
&lt;br /&gt;
To cancel the edit operation, all we have to do is redirect back to the main view:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;/**&lt;br /&gt;
 * cancel editing a record&lt;br /&gt;
 * @return void&lt;br /&gt;
 */&lt;br /&gt;
function cancel()&lt;br /&gt;
{&lt;br /&gt;
    $msg = JText::_( &#039;Operation Cancelled&#039; );&lt;br /&gt;
    $this-&amp;gt;setRedirect( &#039;index.php?option=com_hello&#039;, $msg );&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
We have now implemented a basic backend to our component. We are now able to edit the entries that are viewed in the frontend. We have demonstrated the interaction between models, views and controllers. We have shown how the JTable class can be extended to provide easy access to tables in the database. It can also be seen how the JToolBarHelper class can be used to create button bars in components to present a standardized look between components.&lt;br /&gt;
&lt;br /&gt;
== Other Articles in this Series ==&lt;br /&gt;
[[Developing a Model-View-Controller Component - Part 1]]&lt;br /&gt;
&lt;br /&gt;
[[Developing a Model-View-Controller Component - Part 2 - Adding a Model]]&lt;br /&gt;
&lt;br /&gt;
[[Developing a Model-View-Controller Component - Part 3 - Using the Database]]&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
* staalanden&lt;br /&gt;
* jamesconroyuk&lt;br /&gt;
&lt;br /&gt;
== Download ==&lt;br /&gt;
&lt;br /&gt;
The component can be downloaded at: [http://joomlacode.org/gf/download/frsrelease/8111/29436/com_hello4_01.zip com_hello4_01]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J1.5:Developing_a_MVC_Component/Using_the_Database&amp;diff=13906</id>
		<title>J1.5:Developing a MVC Component/Using the Database</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J1.5:Developing_a_MVC_Component/Using_the_Database&amp;diff=13906"/>
		<updated>2009-04-15T07:09:40Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: cat&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
In the first two tutorials, we showed you how to build a simple model-view-controller component. We had one view which retrieved data from a model (which was created in the 2nd tutorial). In this tutorial, we will be working with the model. Instead of the data being hard coded in the model, the model will retrieve the data from a table in the database.&lt;br /&gt;
&lt;br /&gt;
This tutorial will demonstrate how to use the JDatabase class to retrieve data from the database.&lt;br /&gt;
&lt;br /&gt;
== Retrieving the Data ==&lt;br /&gt;
&lt;br /&gt;
Our model currently has one method: getGreeting(). This method is very simple - all it does is return the hard-coded greeting.&lt;br /&gt;
&lt;br /&gt;
To make things more interesting, we will load the greeting from a database table. We will demonstrate later how to create an SQL file and add the appropriate code to the XML manifest file so that the table and some sample data will be created when the component is installed. For now, we will simply replace our return statement with some code that will retrieve the greeting from the database and return it.&lt;br /&gt;
&lt;br /&gt;
The first step is to obtain a reference to a database object. Since Joomla! uses the database for its normal operation, a database connection already exists; therefore, it is not necessary to create your own. A reference to the existing database can be obtained using:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;$db =&amp;amp; JFactory::getDBO();&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JFactory is a static class that is used to retrieve references to many of the system objects. More information about this class can be found in the API documentation.&lt;br /&gt;
&lt;br /&gt;
The method name (getDBO) stands for get DataBase Object, and is easy and important to remember.&lt;br /&gt;
&lt;br /&gt;
Now that we have obtained a reference to the database object, we can retrieve our data. We do this in two steps:&lt;br /&gt;
&lt;br /&gt;
* store our query in the database object&lt;br /&gt;
* load the result&lt;br /&gt;
&lt;br /&gt;
Our new getGreeting() method will therefore look like:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;function getGreeting()&lt;br /&gt;
{&lt;br /&gt;
   $db =&amp;amp; JFactory::getDBO();&lt;br /&gt;
&lt;br /&gt;
   $query = &#039;SELECT greeting FROM #__hello&#039;;&lt;br /&gt;
   $db-&amp;gt;setQuery( $query );&lt;br /&gt;
   $greeting = $db-&amp;gt;loadResult();&lt;br /&gt;
&lt;br /&gt;
   return $greeting;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
hello is the name of the table that we will create later, and greeting is the name of the field that stores the greetings. If you are not familiar with SQL, it would be helpful to take a tutorial or a lesson to get yourself up to speed. One such tutorial can be found at [http://www.w3schools.com/sql/default.asp w3schools].&lt;br /&gt;
&lt;br /&gt;
The $db-&amp;gt;loadResult() method will execute the stored database query and return the first field of the first row of the result. See [http://api.joomla.org/Joomla-Framework/Database/JDatabase.html JDatabase API reference] for more information about other load methods in the JDatabase class.&lt;br /&gt;
&lt;br /&gt;
== Creating the Installation SQL File ==&lt;br /&gt;
&lt;br /&gt;
The Joomla! installer has built-in support for executing queries during component installation. These queries are all stored in a standard text file.&lt;br /&gt;
&lt;br /&gt;
We will have three queries in our install file: the first will drop the table in case it already exists, the second will create the table with the appropriate fields, and the third will insert the data.&lt;br /&gt;
&lt;br /&gt;
Here are our queries:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;DROP TABLE IF EXISTS `#__hello`;&lt;br /&gt;
&lt;br /&gt;
CREATE TABLE `#__hello` (&lt;br /&gt;
  `id` int(11) NOT NULL auto_increment,&lt;br /&gt;
  `greeting` varchar(25) NOT NULL,&lt;br /&gt;
  PRIMARY KEY  (`id`)&lt;br /&gt;
) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;&lt;br /&gt;
&lt;br /&gt;
INSERT INTO `#__hello` (`greeting`) VALUES (&#039;Hello, World!&#039;),&lt;br /&gt;
(&#039;Bonjour, Monde!&#039;),&lt;br /&gt;
(&#039;Ciao, Mondo!&#039;);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You might find the  prefix on the table names rather odd. Joomla! will replace this prefix with the prefix used by the current install. For most installs, this table will become jos_hello. This allows multiple installs of Joomla! to use the same database, and prevents collisions with other applications using the same table names (i.e. two applications might share a database, but might both require a &#039;users&#039; table. This convention avoids problems.)&lt;br /&gt;
&lt;br /&gt;
We have specified two fields in our database. The first field is id, and is called the &#039;primary key&#039;. The primary key of a database table is a field that is used to uniquely identify a record. This is often used to lookup rows in the database. The other field is greeting. This is the field that stores the greeting that is returned from the query that we used above.&lt;br /&gt;
&lt;br /&gt;
We will save our queries in a file called install.utf.sql.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Uninstall SQL File ===&lt;br /&gt;
&lt;br /&gt;
Though we might hope that people will never want to uninstall our component, it is important that if they do, we don&#039;t leave anything behind. Joomla! will look after deleting the files and directories that were created during install, but you must manually include queries that will remove any tables that have been added to the database. Since we have only created one table, we only need one query:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;DROP TABLE IF EXISTS `#__hello`;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will save this query in a file called uninstall.utf.sql.&lt;br /&gt;
&lt;br /&gt;
== Updating our Install File ==&lt;br /&gt;
&lt;br /&gt;
We need to change a few things in our install file. First, we need to add our two new files to the list of files to install. SQL install file have to go in the admin directory. Second, we need to tell the installer to execute the queries in our files on install and uninstall.&lt;br /&gt;
&lt;br /&gt;
Our new file looks like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;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;install type=&amp;quot;component&amp;quot; version=&amp;quot;1.5.0&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;name&amp;gt;Hello&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;2007-02-22&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;3.01&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;Description of the component ...&amp;lt;/description&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;controller.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;hello.php&amp;lt;/filename&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;models/hello.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;models/index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;views/index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;views/hello/index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;views/hello/view.html.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;views/hello/tmpl/default.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;views/hello/tmpl/index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
 &amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;install&amp;gt;&lt;br /&gt;
  &amp;lt;sql&amp;gt;&lt;br /&gt;
   &amp;lt;file charset=&amp;quot;utf8&amp;quot; driver=&amp;quot;mysql&amp;quot;&amp;gt;install.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;&lt;br /&gt;
  &amp;lt;sql&amp;gt;&lt;br /&gt;
   &amp;lt;file charset=&amp;quot;utf8&amp;quot; driver=&amp;quot;mysql&amp;quot;&amp;gt;uninstall.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;
&lt;br /&gt;
 &amp;lt;administration&amp;gt;&lt;br /&gt;
  &amp;lt;!-- Administration Menu Section --&amp;gt;&lt;br /&gt;
  &amp;lt;menu&amp;gt;Hello World!&amp;lt;/menu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- Administration Main File Copy Section --&amp;gt;&lt;br /&gt;
  &amp;lt;files folder=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;filename&amp;gt;hello.php&amp;lt;/filename&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;install.sql&amp;lt;/filename&amp;gt;&lt;br /&gt;
   &amp;lt;filename&amp;gt;uninstall.sql&amp;lt;/filename&amp;gt;&lt;br /&gt;
&amp;lt;/files&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/administration&amp;gt;&lt;br /&gt;
&amp;lt;/install&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will notice two attributes present on the &amp;lt;file&amp;gt; tags within the &amp;lt;install&amp;gt; and &amp;lt;uninstall&amp;gt; sections: charset and driver. The charset is the type of charset to use. The only valid charset is utf8. If you want to create install files for non-utf8 databases (for older version of MySQL), you should omit this attribute.&lt;br /&gt;
&lt;br /&gt;
The driver attribute specifies which database the queries were written for. Currently, this can only be mysql, but in future versions of Joomla! there may be more database drivers available.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
We now have a component that takes advantage of both the Joomla! MVC framework classes and the JDatabase classes. You are now able to write MVC components that interact with the database and can use the Joomla! installer to create and populate database tables.&lt;br /&gt;
&lt;br /&gt;
== Other Articles in this Series ==&lt;br /&gt;
[[Developing a Model-View-Controller Component - Part 1]]&lt;br /&gt;
&lt;br /&gt;
[[Developing a Model-View-Controller Component - Part 2 - Adding a Model]]&lt;br /&gt;
&lt;br /&gt;
[[Developing a Model-View-Controller Component - Part 4 - Creating an Administrator Interface]]&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
* staalanden&lt;br /&gt;
&lt;br /&gt;
== Download ==&lt;br /&gt;
&lt;br /&gt;
The component can be downloaded at: [http://joomlacode.org/gf/download/frsrelease/8110/29435/com_hello3_01.zip com_hello3_01]&lt;br /&gt;
&lt;br /&gt;
[[Category:Database]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J1.5:Developing_a_MVC_Component/Adding_a_Model&amp;diff=13905</id>
		<title>J1.5:Developing a MVC Component/Adding a Model</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J1.5:Developing_a_MVC_Component/Adding_a_Model&amp;diff=13905"/>
		<updated>2009-04-15T07:09:27Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: cat&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
In the first tutorial of this series, creating a simple view-controller component using the Joomla! 1.5 CMS framework was demonstrated.&lt;br /&gt;
&lt;br /&gt;
In the first tutorial, the greeting was hardcoded into the view. This doesn&#039;t follow the MVC pattern exactly because the view is intended to only display the data, and not contain it.&lt;br /&gt;
&lt;br /&gt;
In this second part of the tutorial we will demonstrate how to move this out of the view and into a model. In future tutorials we will demonstrate the power and flexibility that this design pattern provides.&lt;br /&gt;
&lt;br /&gt;
== Creating the Model ==&lt;br /&gt;
&lt;br /&gt;
The concept of model gets its name because this class is intended to represent (or &#039;model&#039;) some entity. In our case, our first model will represent a &#039;hello&#039;, or a greeting. This is in line with our design thus far, because we have one view (&#039;hello&#039;), which is a view of our greeting.&lt;br /&gt;
&lt;br /&gt;
The naming convention for models in the Joomla! framework is that the class name starts with the name of the component (in our case &#039;hello&#039;, followed by &#039;model&#039;, followed by the model name. Therefore, our model class is called HelloModelHello.&lt;br /&gt;
&lt;br /&gt;
At this point, we will only model one behaviour of our hello, and that is retrieving the greeting. We will thus have one method, called getGreeting(). It will simply return the string &#039;Hello, World!&#039;.&lt;br /&gt;
&lt;br /&gt;
Here is the code for our model class:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Hello Model for Hello World Component&lt;br /&gt;
 * &lt;br /&gt;
 * @package    Joomla.Tutorials&lt;br /&gt;
 * @subpackage Components&lt;br /&gt;
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_2&lt;br /&gt;
 * @license    GNU/GPL&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// No direct access&lt;br /&gt;
&lt;br /&gt;
defined( &#039;_JEXEC&#039; ) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
jimport( &#039;joomla.application.component.model&#039; );&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Hello Model&lt;br /&gt;
 *&lt;br /&gt;
 * @package    Joomla.Tutorials&lt;br /&gt;
 * @subpackage Components&lt;br /&gt;
 */&lt;br /&gt;
class HelloModelHello extends JModel&lt;br /&gt;
{&lt;br /&gt;
    /**&lt;br /&gt;
    * Gets the greeting&lt;br /&gt;
    * @return string The greeting to be displayed to the user&lt;br /&gt;
    */&lt;br /&gt;
    function getGreeting()&lt;br /&gt;
    {&lt;br /&gt;
        return &#039;Hello, World!&#039;;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will notice a line that starts with jimport. The jimport function is used to load files from the Joomla! framework that are required for our component. This particular statement will load the file /libraries/joomla/application/component/model.php. The &#039;.&#039;s are used as directory separators and the last part is the name of the file to load. All files are loaded relative to the libraries directory. This particular file contains the class definition for the JModel class, which is necessary because our model extends this class.&lt;br /&gt;
&lt;br /&gt;
Now that we have created our model, we must modify our view so that it uses it to obtain the greeting.&lt;br /&gt;
&lt;br /&gt;
== Using the Model ==&lt;br /&gt;
&lt;br /&gt;
The Joomla! framework is setup in such a way that the controller will automatically load the model that has the same name as the view and will push it into the view. Since our view is called &#039;Hello&#039;, our &#039;Hello&#039; model will automatically be loaded and pushed into the view. Therefore, we can easily retrieve a reference to our model using the JView::getModel() method. (If the model had not followed this convention, we could have passed the model name to [http://api.joomla.org/Joomla-Framework/Application/JView.html#getModel JView::getModel()])&lt;br /&gt;
&lt;br /&gt;
Our previous view code contained the lines:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;$greeting = &amp;quot;Hello World!&amp;quot;;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To take advantage of our model, we change this line to:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;$model =&amp;amp; $this-&amp;gt;getModel();&lt;br /&gt;
$greeting = $model-&amp;gt;getGreeting();&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The complete view now looks like:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * @package    Joomla.Tutorials&lt;br /&gt;
 * @subpackage Components&lt;br /&gt;
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_2&lt;br /&gt;
 * @license    GNU/GPL&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
// No direct access&lt;br /&gt;
&lt;br /&gt;
defined( &#039;_JEXEC&#039; ) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
jimport( &#039;joomla.application.component.view&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * HTML View class for the HelloWorld Component&lt;br /&gt;
 *&lt;br /&gt;
 * @package    HelloWorld&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
class HelloViewHello extends JView&lt;br /&gt;
{&lt;br /&gt;
    function display($tpl = null)&lt;br /&gt;
    {&lt;br /&gt;
        $model =&amp;amp; $this-&amp;gt;getModel();&lt;br /&gt;
        $greeting = $model-&amp;gt;getGreeting();&lt;br /&gt;
        $this-&amp;gt;assignRef( &#039;greeting&#039;,	$greeting );&lt;br /&gt;
&lt;br /&gt;
        parent::display($tpl);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding the File to the Package ===&lt;br /&gt;
&lt;br /&gt;
All that remains is to add an entry to the XML file so that our new model will be copied. The Joomla! framework will look for our model in the models directory, so the entry for this file will look like (it should be added to the site section):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;filename&amp;gt;models/hello.php&amp;lt;/filename&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our new hello.xml file will look like:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;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;install type=&amp;quot;component&amp;quot; version=&amp;quot;1.5.0&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;name&amp;gt;Hello&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;2007-02-22&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;1.01&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;Description of the component ...&amp;lt;/description&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;controller.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;hello.php&amp;lt;/filename&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;models/hello.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;models/index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;views/index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;views/hello/index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;views/hello/view.html.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;views/hello/tmpl/default.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;views/hello/tmpl/index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
 &amp;lt;/files&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&amp;gt;Hello World!&amp;lt;/menu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- Administration Main File Copy Section --&amp;gt;&lt;br /&gt;
  &amp;lt;files folder=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;filename&amp;gt;hello.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
   &amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;/files&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/administration&amp;gt;&lt;br /&gt;
&amp;lt;/install&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
We now have a simple MVC component. Each element is very simple at this point, but provides a great deal of flexibility and power.&lt;br /&gt;
&lt;br /&gt;
== Other Articles in this Series ==&lt;br /&gt;
[[Developing a Model-View-Controller Component - Part 1]]&lt;br /&gt;
&lt;br /&gt;
[[Developing a Model-View-Controller Component - Part 3 - Using the Database]]&lt;br /&gt;
&lt;br /&gt;
[[Developing a Model-View-Controller Component - Part 4 - Creating an Administrator Interface]]&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
* staalanden&lt;br /&gt;
&lt;br /&gt;
== Download ==&lt;br /&gt;
&lt;br /&gt;
The component can be downloaded at: [http://joomlacode.org/gf/download/frsrelease/8109/29434/com_hello2_01.zip com_hello2_01]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J1.5:Developing_a_MVC_Component/Introduction&amp;diff=13904</id>
		<title>J1.5:Developing a MVC Component/Introduction</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J1.5:Developing_a_MVC_Component/Introduction&amp;diff=13904"/>
		<updated>2009-04-15T07:09:17Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: cat&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
A software framework is the base of an application that can be used by a developer. The framework in Joomla! 1.5 unleashes a great deal of power for them. The Joomla! code has been completely overhauled and cleaned up. This tutorial will guide you through the process of developing a component using the framework.&lt;br /&gt;
&lt;br /&gt;
The scope of this project will be to develop a simple Hello World! component. In future tutorials, this simple framework will be built upon to show the full power and versatility of the MVC design pattern in Joomla!&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
You need Joomla! 1.5 or greater for this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Introduction to Model-View-Controller ==&lt;br /&gt;
While the idea behind a component may seem extremely simple, code can quickly become very complex as additional features are added or the interface is customized.&lt;br /&gt;
&lt;br /&gt;
Model-View-Controller (herein referred to as MVC) is a software design pattern that can be used to organize code in such a way that the business logic and data presentation are separate. The premise behind this approach is that if the business logic is grouped into one section, then the interface and user interaction that surrounds the data can be revised and customized without having to reprogram the business logic.&lt;br /&gt;
&lt;br /&gt;
There are three main parts of an MVC component. They are described here in brief, but for a more thorough explanation, please refer to the links provided at the end of this tutorial.&lt;br /&gt;
&lt;br /&gt;
=== Model ===&lt;br /&gt;
The model is the part of the component that encapsulates the application&#039;s data. It will often provide routines to manage and manipulate this data in a meaningful way in addition to routines that retrieve the data from the model. In our case, the model will contain methods to add, remove and update information about the greetings in the database. It will also contain methods to retrieve the list of greetings from the database. In general, the underlying data access technique should be encapsulated in the model. In this way, if an application is to be moved from a system that utilizes a flat file to store its information to a system that uses a database, the model is the only element that needs to be changed, not the view or the controller.&lt;br /&gt;
&lt;br /&gt;
=== View ===&lt;br /&gt;
The view is the part of the component that is used to render the data from the model in a manner that is suitable for interaction. For a web-based application, the view would generally be an HTML page that is returned to the data. The view pulls data from the model (which is passed to it from the controller) and feeds the data into a template which is populated and presented to the user. The view does not cause the data to be modified in any way, it only displays data retrieved from the model.&lt;br /&gt;
&lt;br /&gt;
=== Controller ===&lt;br /&gt;
The controller is responsible for responding to user actions. In the case of a web application, a user action is (generally) a page request. The controller will determine what request is being made by the user and respond appropriately by triggering the model to manipulate the data appropriately and passing the model into the view. The controller does not display the data in the model, it only triggers methods in the model which modify the data, and then pass the model into the view which displays the data.&lt;br /&gt;
&lt;br /&gt;
== Joomla! MVC Implementation ==&lt;br /&gt;
In Joomla!, the MVC pattern is implemented using three classes: [http://api.joomla.org/Joomla-Framework/Application/JModel.html JModel], [http://api.joomla.org/Joomla-Framework/Application/JView.html JView] and [http://api.joomla.org/Joomla-Framework/Application/JController.html JController]. For more detailed information about these classes, please refer to the API reference documentation (WIP).&lt;br /&gt;
&lt;br /&gt;
== Creating a Component ==&lt;br /&gt;
For our basic component, we only require five files:&lt;br /&gt;
&lt;br /&gt;
* hello.php - this is the entry point to our component&lt;br /&gt;
* controller.php - this file contains our base controller&lt;br /&gt;
* views/hello/view.html.php - this file retrieves the necessary data and pushes it into the template&lt;br /&gt;
* views/hello/tmpl/default.php - this is the template for our output&lt;br /&gt;
* hello.xml - this is an XML file that tells Joomla! how to install our component.&lt;br /&gt;
&lt;br /&gt;
Remember that the filename for the entry point must have the same name of the component. For example, if you call your component &amp;quot;Very Intricate Name Component&amp;quot;, at the install time (see below in the hello.xml section) Joomla! will create the folder com_veryintricatenamecomponent and the entry point php file must be named veryintricatenamecomponent.php otherwise it will not work. Be aware that use of some special characters, notibly the underscore &#039;_&#039;, may have special meaning in Joomla and should be avoided in component names or files.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Entry Point ===&lt;br /&gt;
Joomla! is always accessed through a single point of entry: index.php for the Site Application or administrator/index.php for the Administrator Application. The application will then load the required component, based on the value of &#039;option&#039; in the URL or in the POST data. For our component, the URL would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;index.php?option=com_hello&amp;amp;view=hello&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will load our main file, which can be seen as the single point of entry for our component: components/com_hello/hello.php.&lt;br /&gt;
&lt;br /&gt;
The code for this file is fairly typical across components.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * @package    Joomla.Tutorials&lt;br /&gt;
 * @subpackage Components&lt;br /&gt;
 * components/com_hello/hello.php&lt;br /&gt;
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1&lt;br /&gt;
 * @license    GNU/GPL&lt;br /&gt;
*/&lt;br /&gt;
&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;
// Require the base controller&lt;br /&gt;
&lt;br /&gt;
require_once( JPATH_COMPONENT.DS.&#039;controller.php&#039; );&lt;br /&gt;
&lt;br /&gt;
// Require specific controller if requested&lt;br /&gt;
if($controller = JRequest::getWord(&#039;controller&#039;)) {&lt;br /&gt;
    $path = JPATH_COMPONENT.DS.&#039;controllers&#039;.DS.$controller.&#039;.php&#039;;&lt;br /&gt;
    if (file_exists($path)) {&lt;br /&gt;
        require_once $path;&lt;br /&gt;
    } else {&lt;br /&gt;
        $controller = &#039;&#039;;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Create the controller&lt;br /&gt;
$classname    = &#039;HelloController&#039;.$controller;&lt;br /&gt;
$controller   = new $classname( );&lt;br /&gt;
&lt;br /&gt;
// Perform the Request task&lt;br /&gt;
$controller-&amp;gt;execute( JRequest::getVar( &#039;task&#039; ) );&lt;br /&gt;
&lt;br /&gt;
// Redirect if set by the controller&lt;br /&gt;
$controller-&amp;gt;redirect();&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first statement is a security check.&lt;br /&gt;
&lt;br /&gt;
JPATH_COMPONENT is the absolute path to the current component, in our case components/com_hello. If you specifically need either the Site component or the Administrator component, you can use JPATH_COMPONENT_SITE or JPATH_COMPONENT_ADMINISTRATOR.&lt;br /&gt;
&lt;br /&gt;
DS is the directory separator of your system: either &#039;/&#039; or &#039;\&#039;. This is automatically set by the framework so the developer doesn&#039;t have to worry about developing different versions for different server OSs. DS should always be used when referring to files on the local server.&lt;br /&gt;
&lt;br /&gt;
After loading the base controller, we check if a specific controller is needed. In this component, the base controller is the only controller, but we will leave this here for future use.&lt;br /&gt;
&lt;br /&gt;
JRequest:getVar() finds a variable in the URL or the POST data. So if our URL is index.php?option=com_hello&amp;amp;controller=controller_name, then we can retrieve our controller name in our component using: echo JRequest::getVar(&#039;controller&#039;);&lt;br /&gt;
&lt;br /&gt;
Now we have our base controller &#039;HelloController&#039; in com_hello/controller.php, and, if needed, additional controllers like &#039;HelloControllerController1&#039; in com_hello/controllers/controller1.php. Using this standard naming scheme will make things easy later on: &#039;{Componentname}{Controller}{Controllername}&#039;&lt;br /&gt;
&lt;br /&gt;
After the controller is created, we instruct the controller to execute the task, as defined in the URL: index.php?option=com_hello&amp;amp;task=sometask. If no task is set, the default task &#039;display&#039; will be assumed. When display is used, the &#039;view&#039; variable will decide what will be displayed. Other common tasks are save, edit, new...&lt;br /&gt;
&lt;br /&gt;
The controller might decide to redirect the page, usually after a task like &#039;save&#039; has been completed. This last statement takes care of the actual redirection.&lt;br /&gt;
&lt;br /&gt;
The main entry point (hello.php) essentially passes control to the controller, which handles performing the task that was specified in the request.&lt;br /&gt;
&lt;br /&gt;
Note that we don&#039;t use a closing php tag in this file: ?&amp;gt;. The reason for this is that we will not have any unwanted whitespace in the output code. This is default practice since Joomla! 1.5, and will be used for all php-only files.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Controller ===&lt;br /&gt;
Our component only has one task - greet the world. Therefore, the controller will be very simple. No data manipulation is required. All that needs to be done is the appropriate view loaded. We will have only one method in our controller: display(). Most of the required functionality is built into the JController class, so all that we need to do is invoke the JController::display() method.&lt;br /&gt;
&lt;br /&gt;
The code for the base controller is:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * @package    Joomla.Tutorials&lt;br /&gt;
 * @subpackage Components&lt;br /&gt;
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1&lt;br /&gt;
 * @license    GNU/GPL&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// No direct access&lt;br /&gt;
&lt;br /&gt;
defined( &#039;_JEXEC&#039; ) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
jimport(&#039;joomla.application.component.controller&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Hello World Component Controller&lt;br /&gt;
 *&lt;br /&gt;
 * @package    Joomla.Tutorials&lt;br /&gt;
 * @subpackage Components&lt;br /&gt;
 */&lt;br /&gt;
class HelloController extends JController&lt;br /&gt;
{&lt;br /&gt;
    /**&lt;br /&gt;
     * Method to display the view&lt;br /&gt;
     *&lt;br /&gt;
     * @access    public&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;
The JController constructor will always register a display() task and unless otherwise specified (using the registerDefaultTask() method), it will set it as the default task.&lt;br /&gt;
&lt;br /&gt;
This barebones display() method isn&#039;t really even necessary since all it does is invoke the parent constructor. However, it is a good visual clue to indicate what is happening in the controller.&lt;br /&gt;
&lt;br /&gt;
The JController::display() method will determine the name of the view and layout from the request and load that view and set the layout. When you create a menu item for your component, the menu manager will allow the administrator to select the view that they would like the menu link to display and to specify the layout. A view usually refers to a view of a certain set of data (i.e. a list of cars, a list of events, a single car, a single event). A layout is a way that that view is organized.&lt;br /&gt;
&lt;br /&gt;
In our component, we will have a single view called hello, and a single layout (default).&lt;br /&gt;
&lt;br /&gt;
=== Creating the View ===&lt;br /&gt;
The task of the view is very simple: It retrieves the data to be displayed and pushes it into the template. Data is pushed into the template using the JView::assignRef method.&lt;br /&gt;
&lt;br /&gt;
The code for the view is:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * @package    Joomla.Tutorials&lt;br /&gt;
 * @subpackage Components&lt;br /&gt;
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1&lt;br /&gt;
 * @license    GNU/GPL&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
// no direct access&lt;br /&gt;
&lt;br /&gt;
defined( &#039;_JEXEC&#039; ) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
jimport( &#039;joomla.application.component.view&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * HTML View class for the HelloWorld Component&lt;br /&gt;
 *&lt;br /&gt;
 * @package    HelloWorld&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
class HelloViewHello extends JView&lt;br /&gt;
{&lt;br /&gt;
    function display($tpl = null)&lt;br /&gt;
    {&lt;br /&gt;
        $greeting = &amp;quot;Hello World!&amp;quot;;&lt;br /&gt;
        $this-&amp;gt;assignRef( &#039;greeting&#039;, $greeting );&lt;br /&gt;
&lt;br /&gt;
        parent::display($tpl);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Creating the Template ====&lt;br /&gt;
&lt;br /&gt;
Joomla! templates/layouts are regular PHP files that are used to layout the data from the view in a particular manner. The variables assigned by the JView::assignRef method can be accessed from the template using $this-&amp;gt;{propertyname} (see the template code below for an example).&lt;br /&gt;
&lt;br /&gt;
Our template is very simple: we only want to display the greeting that was passed in from the view:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
// No direct access&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;); ?&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;&amp;lt;?php echo $this-&amp;gt;greeting; ?&amp;gt;&amp;lt;/h1&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Wrapping It All Up - Creating the hello.xml File ===&lt;br /&gt;
It is possible to install a component manually by copying the files using an FTP client and modifying the database tables. It is more efficient to create a package file that will allow the Joomla! Installer to do this for you. This package file contains a variety of information:&lt;br /&gt;
&lt;br /&gt;
* basic descriptive details about your component (i.e. name), and optionally, a description, copyright and license information.&lt;br /&gt;
* a list of files that need to be copied.&lt;br /&gt;
* optionally, a PHP file that performs additional install and uninstall operations.&lt;br /&gt;
* optionally, an SQL file which contains database queries that should be executed upon install/uninstall&lt;br /&gt;
&lt;br /&gt;
The format of the XML file is as follows:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;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;install type=&amp;quot;component&amp;quot; version=&amp;quot;1.5.0&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;name&amp;gt;Hello&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;2007-02-22&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;1.01&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;Description of the component ...&amp;lt;/description&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;controller.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;hello.php&amp;lt;/filename&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;views/index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;views/hello/index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;views/hello/view.html.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;views/hello/tmpl/default.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;filename&amp;gt;views/hello/tmpl/index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
 &amp;lt;/files&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&amp;gt;Hello World!&amp;lt;/menu&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- Administration Main File Copy Section --&amp;gt;&lt;br /&gt;
  &amp;lt;files folder=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;filename&amp;gt;hello.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
   &amp;lt;filename&amp;gt;index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;/files&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/administration&amp;gt;&lt;br /&gt;
&amp;lt;/install&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you look closely you will notice that there are some files that will be copied that we have not discussed. These are the index.html files. An index.html file is placed in each directory to prevent prying users from getting a directory listing. If there is no index.html file, some web servers will list the directory contents. This is often undesirable. These files have the simple line:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;html&amp;gt;&amp;lt;body bgcolor=&amp;quot;#FFFFFF&amp;quot;&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will simply display a blank page.&lt;br /&gt;
&lt;br /&gt;
The other file is the hello.php file. This is the entry point for the admin section of our component. Since we don&#039;t have an admin section of our component, it will have the same content as the index.html files at this point in time.&lt;br /&gt;
&lt;br /&gt;
== Other Articles in this Series ==&lt;br /&gt;
[[Developing a Model-View-Controller Component - Part 2 - Adding a Model]]&lt;br /&gt;
&lt;br /&gt;
[[Developing a Model-View-Controller Component - Part 3 - Using the Database]]&lt;br /&gt;
&lt;br /&gt;
[[Developing a Model-View-Controller Component - Part 4 - Creating an Administrator Interface]]&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
* mjaz&lt;br /&gt;
* staalanden&lt;br /&gt;
&lt;br /&gt;
== Download ==&lt;br /&gt;
The component can be downloaded at: [http://joomlacode.org/gf/download/frsrelease/8108/29433/com_hello1_01.zip com_hello1_01]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:EivindJ&amp;diff=13903</id>
		<title>User:EivindJ</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:EivindJ&amp;diff=13903"/>
		<updated>2009-04-15T07:07:28Z</updated>

		<summary type="html">&lt;p&gt;EivindJ: New page: I&amp;#039;m Trond Eivind Johnsen, a Norwegian web developer, user of Joomla! and experienced MediaWikipedian.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I&#039;m Trond Eivind Johnsen, a Norwegian web developer, user of Joomla! and experienced MediaWikipedian.&lt;/div&gt;</summary>
		<author><name>EivindJ</name></author>
	</entry>
</feed>