<?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=Ch00seLife</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=Ch00seLife"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/Ch00seLife"/>
	<updated>2026-10-17T07:18:54Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J1.5:Creating_a_simple_module&amp;diff=15850</id>
		<title>J1.5:Creating a simple module</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J1.5:Creating_a_simple_module&amp;diff=15850"/>
		<updated>2009-10-08T06:25:03Z</updated>

		<summary type="html">&lt;p&gt;Ch00seLife: Corrected the comment that marks the end of the ModHelloWorld2Helper  class&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{review}}&lt;br /&gt;
== Basic Hello World Module ==&lt;br /&gt;
&lt;br /&gt;
A Joomla! 1.5 Module is in its most basic form two files: an XML configuration file and a PHP controller file. The XML configuration file contains general information about the module (as will be displayed in the Module Manager in the Joomla! administration interface), as well as module parameters which may be supplied to fine tune the appearance / functionality of the module. The PHP file provides the controlling logic for the module. A very simple &amp;quot;Hello World&amp;quot; module might looking something like this.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/modules/mod_hello_world/mod_hello_world.xml:&#039;&#039;&#039;&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;install type=&amp;quot;module&amp;quot; version=&amp;quot;1.5.0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Name of the Module --&amp;gt;&lt;br /&gt;
	&amp;lt;name&amp;gt;Hello World - Hello&amp;lt;/name&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Name of the Author --&amp;gt;&lt;br /&gt;
	&amp;lt;author&amp;gt;Ambitionality Software LLC&amp;lt;/author&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Version Date of the Module --&amp;gt;&lt;br /&gt;
	&amp;lt;creationDate&amp;gt;2008-06-23&amp;lt;/creationDate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Copyright information --&amp;gt;&lt;br /&gt;
	&amp;lt;copyright&amp;gt;All rights reserved by Ambitionality Software LLC 2008.&amp;lt;/copyright&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- License Information --&amp;gt;&lt;br /&gt;
	&amp;lt;license&amp;gt;GPL 2.0&amp;lt;/license&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Author&#039;s email address --&amp;gt;&lt;br /&gt;
	&amp;lt;authorEmail&amp;gt;info@ambitionality.com&amp;lt;/authorEmail&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Author&#039;s website --&amp;gt;&lt;br /&gt;
	&amp;lt;authorUrl&amp;gt;www.ambitionality.com&amp;lt;/authorUrl&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Module version number --&amp;gt;&lt;br /&gt;
	&amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Description of what the module does --&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;Provides a basic &amp;quot;Hello World&amp;quot; notice&amp;lt;/description&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Listing of all files that should be installed for the module to function --&amp;gt;&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;!-- The &amp;quot;module&amp;quot; attribute signifies that this is the main controller file --&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_hello_world&amp;quot;&amp;gt;mod_hello_world.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;!-- Optional parameters --&amp;gt;&lt;br /&gt;
	&amp;lt;params /&amp;gt;&lt;br /&gt;
&amp;lt;/install&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Basically, this XML file just lines out basic information about the module such as the owner, version, etc. for identification by the Joomla! installer and then provides optional parameters which may be set in the Module Manager and accessed from within the module&#039;s logic to fine tune its behavior. Additionally, this file tells the installer which files should be copied and installed. Notice that we DO NOT include a reference in the files section for the XML file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/modules/mod_hello_world/mod_hello_world.php:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
//don&#039;t allow other scripts to grab and execute our file&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Direct Access to this location is not allowed.&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
    Hello World&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What happens when this module is loaded is that Joomla! includes (via the PHP include directive) the mod_hello_world.php file and stores the output into an output buffer which is then rendered onto the page output. This file would simply produce &amp;lt;p&amp;gt;Hello World&amp;lt;/p&amp;gt; to the final page.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/modules/mod_hello_world/index.html:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&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;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This really just helps to ensure that a default page is displayed if direct access to the directory is attempted without listing all of the other files in the directory. It&#039;s not necessary, but is good practice.&lt;br /&gt;
&lt;br /&gt;
To package this module for distribution and installation, simply zip the files together, e.g.,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
% cd mod_hello_world&lt;br /&gt;
% zip mod_hello_world.zip mod_hello_world.php mod_hello_world.xml index.html&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting mod_hello_world.zip file may be uploaded and installed through the standard Joomla! 1.5 Extension Manager.&lt;br /&gt;
&lt;br /&gt;
== Real Joomla! 1.5 Style Module Implementation ==&lt;br /&gt;
&lt;br /&gt;
Now that was easy...too easy. In fact, that was pretty much the simplest form of a module possible. In reality a module will probably be doing something much more substantial. Let&#039;s assume that our modules are going to be more complex - we need to take advantage of the MVC (Model View Controller) design pattern and consider using the following file layout for a &amp;quot;Hello World 2&amp;quot; module instead:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
/modules/mod_hello_world2/index.html&lt;br /&gt;
/modules/mod_hello_world2/mod_hello_world2.php&lt;br /&gt;
/modules/mod_hello_world2/mod_hello_world2.xml&lt;br /&gt;
/modules/mod_hello_world2/helper.php&lt;br /&gt;
/modules/mod_hello_world2/en-GB.mod_hello_world2.ini&lt;br /&gt;
/modules/mod_hello_world2/tmpl/index.html&lt;br /&gt;
/modules/mod_hello_world2/tmpl/default.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The differences to note here are that there are three additional files beyond what the &amp;quot;Hello World&amp;quot; module had, namely helper.php, tmpl/default.php, and the en-GB.mod_hello_world2.ini file. The purpose in adding the first two files is two-fold. Firstly, we separate the module&#039;s logic into the helper.php file to ensure that all of the thinking and data access is performed here and separate out the module&#039;s presentation / template into the tmpl/default.php file (the (X)HTML). I argue that this is just good programming - separating logic from presentation. There is a second advantage to this, however, which is that it will allow the HTML / presentation to be overridden easily by any Joomla! 1.5 template for optimal integration into any site. (Overriding module and component presentation in templates is beyond the scope of this article, however it should be addressed as it&#039;s really useful).&lt;br /&gt;
&lt;br /&gt;
Let&#039;s take a look at what these files might look like and discuss what&#039;s going on.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/modules/mod_hello_world2/mod_hello_world2.php:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
//no direct access&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Direct Access to this location is not allowed.&#039;);&lt;br /&gt;
&lt;br /&gt;
// include the helper file&lt;br /&gt;
require_once(dirname(__FILE__).DS.&#039;helper.php&#039;);&lt;br /&gt;
&lt;br /&gt;
// get a parameter from the module&#039;s configuration&lt;br /&gt;
$userCount = $params-&amp;gt;get(&#039;usercount&#039;);&lt;br /&gt;
&lt;br /&gt;
// get the items to display from the helper&lt;br /&gt;
$items = ModHelloWorld2Helper::getItems($userCount);&lt;br /&gt;
&lt;br /&gt;
// include the template for display&lt;br /&gt;
require(JModuleHelper::getLayoutPath(&#039;mod_hello_world2&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The important differences to note are that (1) we include a helper file which will be the work-horse of our logic and data access and (2) once we have our data, we just load a template which will use our data and render it as it sees fit.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/modules/mod_hello_world2/mod_hello_world2.xml&#039;&#039;&#039;&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;install type=&amp;quot;module&amp;quot; version=&amp;quot;1.5.0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- Name of the Module --&amp;gt;&lt;br /&gt;
	&amp;lt;name&amp;gt;Hello World 2 - Hello&amp;lt;/name&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Name of the Author --&amp;gt;&lt;br /&gt;
	&amp;lt;author&amp;gt;Ambitionality Software LLC&amp;lt;/author&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Version Date of the Module --&amp;gt;&lt;br /&gt;
	&amp;lt;creationDate&amp;gt;2008-06-23&amp;lt;/creationDate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Copyright information --&amp;gt;&lt;br /&gt;
	&amp;lt;copyright&amp;gt;All rights reserved by Ambitionality Software LLC 2008.&amp;lt;/copyright&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- License Information --&amp;gt;&lt;br /&gt;
	&amp;lt;license&amp;gt;GPL 2.0&amp;lt;/license&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Author&#039;s email address --&amp;gt;&lt;br /&gt;
	&amp;lt;authorEmail&amp;gt;info@ambitionality.com&amp;lt;/authorEmail&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Author&#039;s website --&amp;gt;&lt;br /&gt;
	&amp;lt;authorUrl&amp;gt;www.ambitionality.com&amp;lt;/authorUrl&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Module version number --&amp;gt;&lt;br /&gt;
	&amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt; &lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Description of what the module does --&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;Provides a random listing of registered users&amp;lt;/description&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Listing of all files that should be installed for the module to function --&amp;gt;&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;!-- The &amp;quot;module&amp;quot; attribute signifies that this is the main controller file --&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_hello_world2&amp;quot;&amp;gt;mod_hello_world2.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;helper.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;tmpl/default.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;tmpl/index.html&amp;lt;/filename&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;languages&amp;gt;&lt;br /&gt;
        &amp;lt;!-- Any language files included with the module --&amp;gt;&lt;br /&gt;
        &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_hello_world2.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
    &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- Optional parameters --&amp;gt;&lt;br /&gt;
	&amp;lt;params&amp;gt;&lt;br /&gt;
        &amp;lt;!-- parameter to allow placement of a module class suffix for the module table / xhtml display --&amp;gt;&lt;br /&gt;
		&amp;lt;param name=&amp;quot;moduleclass_sfx&amp;quot; type=&amp;quot;text&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;Module Class Suffix&amp;quot; description=&amp;quot;PARAMMODULECLASSSUFFIX&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;!-- just gives us a little room between the previous paramter and the next --&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;
&lt;br /&gt;
        &amp;lt;!-- A parameter that allows an administrator to modify the number of users that this module will display --&amp;gt;&lt;br /&gt;
        &amp;lt;param name=&amp;quot;usercount&amp;quot; type=&amp;quot;text&amp;quot; default=&amp;quot;5&amp;quot; label=&amp;quot;LABEL USER COUNT&amp;quot; description=&amp;quot;DESC USER COUNT&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/params&amp;gt;&lt;br /&gt;
&amp;lt;/install&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main differences to note here are that we have added a language file reference (we could have added more) and we added some parameters.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/modules/mod_hello_world2/helper.php:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Direct Access to this location is not allowed.&#039;);&lt;br /&gt;
&lt;br /&gt;
class ModHelloWorld2Helper&lt;br /&gt;
{&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns a list of post items&lt;br /&gt;
    */&lt;br /&gt;
    public function getItems($userCount)&lt;br /&gt;
    {&lt;br /&gt;
        // get a reference to the database&lt;br /&gt;
        $db = &amp;amp;JFactory::getDBO();&lt;br /&gt;
&lt;br /&gt;
        // get a list of $userCount randomly ordered users &lt;br /&gt;
        $query = &#039;SELECT a.name FROM `#__users` AS a ORDER BY rand() LIMIT &#039; . $userCount  . &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
        $db-&amp;gt;setQuery($query);&lt;br /&gt;
        $items = ($items = $db-&amp;gt;loadObjectList())?$items:array();&lt;br /&gt;
&lt;br /&gt;
        return $items;&lt;br /&gt;
    } //end getItems&lt;br /&gt;
&lt;br /&gt;
} //end ModHelloWorld2Helper&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This helper class (note that it is named for the module name so that it doesn&#039;t collide with other class names) simply retrieves a list of all users in the database and randomly selects a subset of those based upon the number supplied as $userCount.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/modules/mod_hello_world2/tmpl/default.php:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;); // no direct access ?&amp;gt;&lt;br /&gt;
&amp;lt;?php echo JText::_(&#039;RANDOM USERS&#039;); ?&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
    &amp;lt;?php foreach ($items as $item) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&lt;br /&gt;
        &amp;lt;?php echo JText::sprintf(&#039;USER LABEL&#039;, $item-&amp;gt;name); ?&amp;gt;&lt;br /&gt;
    &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here we simply create an unordered HTML list and then iterate through the items returned by our helper (in mod_hello_world2.php), printing out a message with each user&#039;s name.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;/modules/mod_hello_world2/en-GB.mod_hello_world2.ini:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
LABEL USER COUNT=User Count&lt;br /&gt;
DESC USER COUNT=The number of users to display&lt;br /&gt;
RANDOM USERS=Random Users for Hello World2&lt;br /&gt;
USER LABEL=%s is a randomly selected user&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here we simply identify strings which appear in the module configuration file and the module template which appear in JText::_ or JText::sprintf statements. This allows someone to easily write a new language file without editing any of the HTML or code for the module.&lt;br /&gt;
&lt;br /&gt;
Now all we have to do is zip up these files, as in:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
% pwd&lt;br /&gt;
/somesite/modules/mod_hello_world2&lt;br /&gt;
% zip -r ../mod_hello_world2.zip *&lt;br /&gt;
% ls ..&lt;br /&gt;
mod_hello_world2.zip&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting mod_hello_world2.zip file is ready for installation and distribution. When the ZIP file is installed, the en-GB.mod_hello_world2.ini file is copied to /language/en-GB/en-GB.mod_hello_world2.ini and is loaded each time the module is loaded. All of the other files are copied to the /modules/mod_hello_world2 subfolder of the Joomla! installation.&lt;br /&gt;
&amp;lt;noinclude&amp;gt;[[Category:Development]]&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ch00seLife</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Talk:Inserting_a_link_to_another_Article_or_content_page_into_an_Article&amp;diff=14965</id>
		<title>Talk:Inserting a link to another Article or content page into an Article</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Talk:Inserting_a_link_to_another_Article_or_content_page_into_an_Article&amp;diff=14965"/>
		<updated>2009-07-20T06:45:57Z</updated>

		<summary type="html">&lt;p&gt;Ch00seLife: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi I believe the best way to link an Article to another article on the same Joomla website should be just giving it Article ID through the index.php like this:&lt;br /&gt;
&lt;br /&gt;
/index.php?option=com_content&amp;amp;view=article&amp;amp;id=50&amp;amp;Itemid=61&lt;br /&gt;
&lt;br /&gt;
You can always can get to know the Article ID&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
&lt;br /&gt;
Javier&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you turn on Search Engine Friendly URLs (SEF) in the global settings, you can use the alias names in your links. &lt;br /&gt;
Note: test this in your staging/development environment first in case your installation doesn&#039;t work well with SEF.&lt;br /&gt;
-- Added by Ch00seLife on 2009-07-19 at 23:46 Pacific Daylight Time&lt;/div&gt;</summary>
		<author><name>Ch00seLife</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Talk:Inserting_a_link_to_another_Article_or_content_page_into_an_Article&amp;diff=14964</id>
		<title>Talk:Inserting a link to another Article or content page into an Article</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Talk:Inserting_a_link_to_another_Article_or_content_page_into_an_Article&amp;diff=14964"/>
		<updated>2009-07-20T06:44:07Z</updated>

		<summary type="html">&lt;p&gt;Ch00seLife: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{inuse}}&lt;br /&gt;
Hi I believe the best way to link an Article to another article on the same Joomla website should be just giving it Article ID through the index.php like this:&lt;br /&gt;
&lt;br /&gt;
/index.php?option=com_content&amp;amp;view=article&amp;amp;id=50&amp;amp;Itemid=61&lt;br /&gt;
&lt;br /&gt;
You can always can get to know the Article ID&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
&lt;br /&gt;
Javier&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I think that there should be an easy way to do this using aliases. Does anyone else agree?&lt;br /&gt;
-- Added by Ch00seLife on 2009-07-19 at 23:09 Pacific Daylight Time&lt;/div&gt;</summary>
		<author><name>Ch00seLife</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Talk:Inserting_a_link_to_another_Article_or_content_page_into_an_Article&amp;diff=14963</id>
		<title>Talk:Inserting a link to another Article or content page into an Article</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Talk:Inserting_a_link_to_another_Article_or_content_page_into_an_Article&amp;diff=14963"/>
		<updated>2009-07-20T06:09:21Z</updated>

		<summary type="html">&lt;p&gt;Ch00seLife: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi I believe the best way to link an Article to another article on the same Joomla website should be just giving it Article ID through the index.php like this:&lt;br /&gt;
&lt;br /&gt;
/index.php?option=com_content&amp;amp;view=article&amp;amp;id=50&amp;amp;Itemid=61&lt;br /&gt;
&lt;br /&gt;
You can always can get to know the Article ID&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
&lt;br /&gt;
Javier&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I think that there should be an easy way to do this using aliases. Does anyone else agree?&lt;br /&gt;
-- Added by Ch00seLife on 2009-07-19 at 23:09 Pacific Daylight Time&lt;/div&gt;</summary>
		<author><name>Ch00seLife</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=PHP_essentials&amp;diff=14183</id>
		<title>PHP essentials</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=PHP_essentials&amp;diff=14183"/>
		<updated>2009-05-12T07:56:09Z</updated>

		<summary type="html">&lt;p&gt;Ch00seLife: /* Defining array Structures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{review}}&lt;br /&gt;
===PHP essentials===&lt;br /&gt;
----&lt;br /&gt;
Many web designers and casual website owners are not conversant with the&lt;br /&gt;
PHP language in which Joomla! is written and since Joomla! templates&lt;br /&gt;
usually contain PHP statements it is necessary to understand at least a&lt;br /&gt;
little of the language in order to be able to create or customize&lt;br /&gt;
templates. This chunk will describe, in simple terms, how to use each aspect of PHP in the&lt;br /&gt;
context of a Joomla! template. For example, a simple explanation of the PHP&lt;br /&gt;
if-then-else syntax using extracts from a template for illustration.&lt;br /&gt;
&lt;br /&gt;
The best resource to learn PHP is probably hands on experience and Joomla can provide that to you thanks to it&#039;s native PHP code.  This can be overwhelming for people who have not programmed before. Though Joomla is easy enough to [[Installation|install]] with the help of the community and a little of your time you&#039;ll have people asking you to do their websites.&lt;br /&gt;
&lt;br /&gt;
One place that has a nice short list if functions and examples is http://en.wikiversity.org/wiki/25_Essential_PHP_Functions which is good to get familiar with PHP. Though for an extensive function list, explanations, and examples go to http://www.php.net.&lt;br /&gt;
&lt;br /&gt;
Once you have the basics of PHP you&#039;ll need to get the basics of the Joomla PHP syntax.  Start by looking at some existing {{jsite|ext|extensions}} and check out the code and also take a look at some these Tutorials about Joomla:&lt;br /&gt;
&lt;br /&gt;
[http://developer.joomla.org/tutorials/184-how-to-create-a-joomla-plugin.html How to create a Joomla! Plugin]&lt;br /&gt;
&lt;br /&gt;
[http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1 Developing a Model-View-Controller Component - Part 1]&lt;br /&gt;
&lt;br /&gt;
[http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_2_-_Adding_a_Model Developing a Model-View-Controller Component - Part 2 - Adding a Model]&lt;br /&gt;
&lt;br /&gt;
[http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_3_-_Using_the_Database Developing a Model-View-Controller Component - Part 3 - Using the Database]&lt;br /&gt;
&lt;br /&gt;
[http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_4_-_Creating_an_Administrator_Interface Developing a Model-View-Controller Component - Part 4 - Creating an Administrator Interface]&lt;br /&gt;
&lt;br /&gt;
That will help you get familiar with some of the functions available within Joomla&#039;s system and what they do (using the API).  Take particular care to understand the MVC (model view control) setup.&lt;br /&gt;
&lt;br /&gt;
If however, you are absolutely new to PHP, following may help as very brief introduction to PHP.&lt;br /&gt;
&lt;br /&gt;
==== PHP Introduction ====&lt;br /&gt;
PHP is a scripting language and is designed primarily for producing dynamic web pages. It is in general embedded into a HTML page with tags like &amp;lt;?php ... ?&amp;gt;. When such a page is passed on to the PHP engine, the engine translates the PHP tags into HTML and which can then be rendered by a browser. Further during translation the script may require to pull data from a database and thus a database is needed. So for creating PHP pages we require in general, the PHP engine, a database typically MySQL and finally the webserver which will co-ordinate these actions and forward the final HTML to the browser. These 3 components can be installed separately, however, for convenience we have packages like WAMP for windows, MAMP for mac and LAMP for Linux. Installing the packages is discussed next.&lt;br /&gt;
&lt;br /&gt;
==== PHP Installation ====&lt;br /&gt;
The packages can be downloaded from [http://www.wampserver.com/en/download.php WAMP]. WAMP stands for Windows Apache MySQL PHP. The instructions can be followed as given in the site and is pretty straightforward. The installation can be done is any directory (say D:/wamp). Once installed, it can be started from the program-&amp;gt;start-&amp;gt;WampServer. This should give a small icon in the system tray using which the server can be started/stopped/restarted. It also gives links to all important files like php.ini and other configuration files. For Mac users MAMP can be found [http://www.macupdate.com/info.php/id/16197 here]. For the purpose of this tutorial [http://www.apachefriends.org/en/xampp.html XAMPP] can also be used.&lt;br /&gt;
&lt;br /&gt;
==== PHP Round trip ====&lt;br /&gt;
Our primary target here is to write a small PHP page and get it rendered by the Apache web server. To render a page WAMP by default looks into the www folder of the WAMP install directory referred henceforth as WAMP_HOME for convenience. Fire up your primary text editor and create a page say first.php and save it in the WAMP_HOME/www/x/y folder, where x, y are folders (which you can create for organizing your scripts). Write the following in the script&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
   &amp;lt;title&amp;gt;Basic PHP Page&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
echo (&amp;quot;My first php snippet&amp;quot;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save this file and point your browser to http://localhost/x/y/first.php and you should be able to see the echo message. &lt;br /&gt;
&lt;br /&gt;
Primary things to note here are &amp;lt;pre&amp;gt;&lt;br /&gt;
1. It is strongly advised to start any PHP code by &amp;quot;&amp;lt;?php&amp;quot; and end with a &amp;quot;?&amp;gt;&amp;quot; tag. &lt;br /&gt;
2. To have a semicolon after each PHP statement.&lt;br /&gt;
3. The directory in which this script resides needs to be given in the URL. &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This completes our round trip. Now for the sake of learning either you can keep including new elements in this file or may create separate scripts and load them in the browser.&lt;br /&gt;
&lt;br /&gt;
==== PHP Variable declaration and Data types ====&lt;br /&gt;
For any programming we need to hold data. In PHP following are the ways in which you can define variables.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;$variable_name = 0; &amp;lt;/li&amp;gt;&lt;br /&gt;
Note here we did not define what is the type of variable, whether integer or string that the variable should hold. This is referred to as dynamic scoping. &lt;br /&gt;
&amp;lt;li&amp;gt; the variable names should start with an alphabet and can contain alphanumeric characters and &amp;quot;_&amp;quot;&lt;br /&gt;
&amp;lt;li&amp;gt; Defining constants - &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt; define (&amp;quot;NAME_OF_THE_CONSTANT&amp;quot; , $value); &amp;lt;/source&amp;gt; &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Basic operators ====&lt;br /&gt;
The general operators are as below and explained.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
a.	+   e.g. 6 + 3, addition operator, answer is 9&lt;br /&gt;
b.	–   e.g. 6 - 3, subtraction operator, answer is 3&lt;br /&gt;
c.	/   e.g. 6 / 3, division operator, answer is 2&lt;br /&gt;
d.	*   e.g. 6 * 3, multiplication operator, answer is 18&lt;br /&gt;
e.	%   e.g. 6 % 3, modulus operator, answer is 0&lt;br /&gt;
f.	.   e.g. &#039;6&#039;.&#039;3&#039;, concatenation operator, gives string &#039;63&#039;&lt;br /&gt;
g.	+=   e.g. $x += 6, adds 6&lt;br /&gt;
h.	-=   e.g. $x -= 6, subtracts 6&lt;br /&gt;
i.	/=   e.g. $x /= 6, divides by 6&lt;br /&gt;
j.	%=   e.g. $x %= 6, modulus by 6&lt;br /&gt;
k.	.=   e.g. $x .= &#039;6&#039;, concats 6 to x&lt;br /&gt;
l.	&amp;lt;   e.g. $x &amp;lt; $y, evaluates to true if $x is &amp;lt; $y&lt;br /&gt;
m.	&amp;gt;   e.g. $x &amp;gt; $y, evaluates to true if $x is &amp;gt; $y&lt;br /&gt;
n.	==  e.g. $x == $y, evaluates to true if $x is equal by value to $y&lt;br /&gt;
o.	!=  e.g. $x != $y, evaluates to true if $x is not equal to $y&lt;br /&gt;
p.	===   e.g. $x === $y, evaluates to true if $x is and $y is identical i.e both of same type both value and reference&lt;br /&gt;
q.	&amp;gt;=  e.g. $x &amp;gt;= $y, evaluates to true if $x is &amp;gt;= $y&lt;br /&gt;
r.	&amp;lt;=  e.g. $x &amp;lt;= $y, evaluates to true if $x is &amp;lt;= $y&lt;br /&gt;
s.	&amp;amp;&amp;amp;  e.g. ($x == 2 &amp;amp;&amp;amp; $y == 3) , evaluates to true if $x equals 2 and $y equals 3&lt;br /&gt;
t.	||  e.g. ($x == 2 || $y == 3) , evaluates to true if either $x equals 2 or $y equals 3&lt;br /&gt;
u.	xor e.g. ($x == 2 xor $y == 3) , evaluates to true if either $x equals 2 or $y equals 3 but not both&lt;br /&gt;
v.	++  e.g. $x++, increments $x&lt;br /&gt;
w.	–-  e.g. $x--, decrements $x&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Defining array Structures ====&lt;br /&gt;
&#039;&#039;&#039;Ways of declaring arrays&#039;&#039;&#039; &lt;br /&gt;
&amp;lt;br&amp;gt; Suppose we want many variables, we could have done in the way declaring variables as above, however, that is not elegant, for suppose u want a 100 variables; declaring arrays come to the rescue. Note that index in PHP starts from 0.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$my_guitar_heroes = array (&amp;quot;Hendrix&amp;quot;, &amp;quot;Schenker&amp;quot;, &amp;quot;Gilmour&amp;quot;, &amp;quot;to_name_a_few!&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$my_guitar_heroes [] = &amp;quot;Hendrix&amp;quot;;&lt;br /&gt;
$my_guitar_heroes [] = &amp;quot;Schenker&amp;quot;;&lt;br /&gt;
$my_guitar_heroes [] = &amp;quot;Gilmour&amp;quot;;&lt;br /&gt;
$my_guitar_heroes [] = &amp;quot;to_name_a_few!&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here PHP automatically assigns the index.&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$my_guitar_heroes [0] = &amp;quot;Hendrix&amp;quot;;&lt;br /&gt;
$my_guitar_heroes [10000] = &amp;quot;Mainak&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here in I just knew the first element and the 10,001st element and that&#039;s me!&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
a combination of the above means&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Set the elements at positions 1 through 9999 to the value, &amp;quot;to be decided&amp;quot;.&lt;br /&gt;
$my_guitar_heroes  = array_fill( 1, 9999, &amp;quot;to be decided&amp;quot; ); &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Accessing the arrays&#039;&#039;&#039; &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
print $my_guitar_heroes[2]; //Access the 2nd element&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Access the last element (Note that the element positions are numbered zero to &lt;br /&gt;
// [number of elements] minus one.)&lt;br /&gt;
$my_guitar_heroes[count($my_guitar_heroes)-1]; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Access the last element using a function call.&lt;br /&gt;
end($my_guitar_heroes); &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Iterating over the element of an array&#039;&#039;&#039; &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
foreach ( $my_guitar_heroes as $temp) {&lt;br /&gt;
  print &amp;quot;$temp&amp;lt;br /&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Control expressions ====&lt;br /&gt;
To execute a statement of collection of statements over and over, we use Control expressions. The  following are general syntax of the control structures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;if statements&#039;&#039;&#039;&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
if( $x &amp;gt; 0) {	&lt;br /&gt;
 print(&amp;quot;$x is positive&amp;quot;);&lt;br /&gt;
}  else if( $x &amp;lt; 0 ) {	&lt;br /&gt;
 print(&amp;quot;$x is negative&amp;quot;);&lt;br /&gt;
} else {&lt;br /&gt;
 print(&amp;quot;$x is 0&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;for loop&#039;&#039;&#039;&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
for ( $x=1; $x&amp;lt;= 10; $x++ ) {&lt;br /&gt;
 print &amp;quot;$x&amp;lt;BR/&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;while loop&#039;&#039;&#039;&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$x = 1&lt;br /&gt;
while ( $x &amp;lt;= 10 ) {&lt;br /&gt;
 print &amp;quot;$x&amp;lt;BR/&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;do while loop&#039;&#039;&#039;&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$x = 1;&lt;br /&gt;
do {&lt;br /&gt;
 print &amp;quot;$x&amp;lt;BR/&amp;gt;&amp;quot;;&lt;br /&gt;
 $x++;&lt;br /&gt;
}while($x &amp;lt;= 10);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Defining functions ====&lt;br /&gt;
Code which is duplicated at many places are best placed in a function. Following are the ways of describing the function.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
function name_of_the_function( $arguments, $size=&#039;default_values_if_any&#039; ) {&lt;br /&gt;
  print &amp;quot;here goes in the code&amp;quot;; &lt;br /&gt;
  return &amp;quot;this value is returned, return statement is optional&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The arguments are passed by value. If they are to be passed by reference then an argument is prefixed by &amp;quot;&amp;amp;&amp;quot; as below&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
function name_of_the_function( &amp;amp;$arguments, $size=&#039;default_values_if_any&#039; ) {&lt;br /&gt;
  print &amp;quot;here goes in the code&amp;quot;; &lt;br /&gt;
  return &amp;quot;this value is returned, return statement is optional&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Scope of a variables defined within a function is valid within the function only. &lt;br /&gt;
&lt;br /&gt;
Calling a function&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;$x = add(5, 3);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Debugging ====&lt;br /&gt;
&#039;&#039;&#039;Basic printing options&#039;&#039;&#039; &amp;lt;br/&amp;gt;&lt;br /&gt;
A basic way to debug is to print the value of the variable. The following basic statments acheives that&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;echo &amp;quot;if double quotes are used then dollar variables are resolved&amp;quot;;&lt;br /&gt;
&amp;lt;li&amp;gt;echo &#039;if single quote are used then dollar variables are not resolved&#039;;&lt;br /&gt;
&amp;lt;li&amp;gt;print &amp;quot;another way to print&amp;quot;;&lt;br /&gt;
&amp;lt;li&amp;gt;nl2br(&amp;quot;any new line characters like \n get automatically resolved to HTML line breaks&amp;quot;);&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apart from these the log files are very helpful and can be found in the WAMP_HOME/logs directory.&lt;br /&gt;
&lt;br /&gt;
==== Handling forms ====&lt;br /&gt;
PHP does not change any HTML structure, thus any syntax of HTML remains the same. The part that PHP plays is making any part dynamic for e.g the action attribute of a form can be coded as action=&amp;lt;?php my_own_action(); ?&amp;gt; so that it is dynamically generated. The part where PHP kicks in is after the form is submitted, to say obtain the values of the form fields, set cookies etc. For this super global variables are used which are always available to PHP code. Some of these are  &lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;$_GET - get the data from a GET request&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;$_POST - get the data from a POST request&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;$_REQUEST - get the request&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;$_COOKIE - obtain the cookies from the browser&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;$_SESSION - obtain the session&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All of these are arrays and behave accordingly.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[Category:Templates]]&lt;/div&gt;</summary>
		<author><name>Ch00seLife</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=PHP_essentials&amp;diff=14182</id>
		<title>PHP essentials</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=PHP_essentials&amp;diff=14182"/>
		<updated>2009-05-12T07:54:09Z</updated>

		<summary type="html">&lt;p&gt;Ch00seLife: /* Defining array Structures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{review}}&lt;br /&gt;
===PHP essentials===&lt;br /&gt;
----&lt;br /&gt;
Many web designers and casual website owners are not conversant with the&lt;br /&gt;
PHP language in which Joomla! is written and since Joomla! templates&lt;br /&gt;
usually contain PHP statements it is necessary to understand at least a&lt;br /&gt;
little of the language in order to be able to create or customize&lt;br /&gt;
templates. This chunk will describe, in simple terms, how to use each aspect of PHP in the&lt;br /&gt;
context of a Joomla! template. For example, a simple explanation of the PHP&lt;br /&gt;
if-then-else syntax using extracts from a template for illustration.&lt;br /&gt;
&lt;br /&gt;
The best resource to learn PHP is probably hands on experience and Joomla can provide that to you thanks to it&#039;s native PHP code.  This can be overwhelming for people who have not programmed before. Though Joomla is easy enough to [[Installation|install]] with the help of the community and a little of your time you&#039;ll have people asking you to do their websites.&lt;br /&gt;
&lt;br /&gt;
One place that has a nice short list if functions and examples is http://en.wikiversity.org/wiki/25_Essential_PHP_Functions which is good to get familiar with PHP. Though for an extensive function list, explanations, and examples go to http://www.php.net.&lt;br /&gt;
&lt;br /&gt;
Once you have the basics of PHP you&#039;ll need to get the basics of the Joomla PHP syntax.  Start by looking at some existing {{jsite|ext|extensions}} and check out the code and also take a look at some these Tutorials about Joomla:&lt;br /&gt;
&lt;br /&gt;
[http://developer.joomla.org/tutorials/184-how-to-create-a-joomla-plugin.html How to create a Joomla! Plugin]&lt;br /&gt;
&lt;br /&gt;
[http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1 Developing a Model-View-Controller Component - Part 1]&lt;br /&gt;
&lt;br /&gt;
[http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_2_-_Adding_a_Model Developing a Model-View-Controller Component - Part 2 - Adding a Model]&lt;br /&gt;
&lt;br /&gt;
[http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_3_-_Using_the_Database Developing a Model-View-Controller Component - Part 3 - Using the Database]&lt;br /&gt;
&lt;br /&gt;
[http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_4_-_Creating_an_Administrator_Interface Developing a Model-View-Controller Component - Part 4 - Creating an Administrator Interface]&lt;br /&gt;
&lt;br /&gt;
That will help you get familiar with some of the functions available within Joomla&#039;s system and what they do (using the API).  Take particular care to understand the MVC (model view control) setup.&lt;br /&gt;
&lt;br /&gt;
If however, you are absolutely new to PHP, following may help as very brief introduction to PHP.&lt;br /&gt;
&lt;br /&gt;
==== PHP Introduction ====&lt;br /&gt;
PHP is a scripting language and is designed primarily for producing dynamic web pages. It is in general embedded into a HTML page with tags like &amp;lt;?php ... ?&amp;gt;. When such a page is passed on to the PHP engine, the engine translates the PHP tags into HTML and which can then be rendered by a browser. Further during translation the script may require to pull data from a database and thus a database is needed. So for creating PHP pages we require in general, the PHP engine, a database typically MySQL and finally the webserver which will co-ordinate these actions and forward the final HTML to the browser. These 3 components can be installed separately, however, for convenience we have packages like WAMP for windows, MAMP for mac and LAMP for Linux. Installing the packages is discussed next.&lt;br /&gt;
&lt;br /&gt;
==== PHP Installation ====&lt;br /&gt;
The packages can be downloaded from [http://www.wampserver.com/en/download.php WAMP]. WAMP stands for Windows Apache MySQL PHP. The instructions can be followed as given in the site and is pretty straightforward. The installation can be done is any directory (say D:/wamp). Once installed, it can be started from the program-&amp;gt;start-&amp;gt;WampServer. This should give a small icon in the system tray using which the server can be started/stopped/restarted. It also gives links to all important files like php.ini and other configuration files. For Mac users MAMP can be found [http://www.macupdate.com/info.php/id/16197 here]. For the purpose of this tutorial [http://www.apachefriends.org/en/xampp.html XAMPP] can also be used.&lt;br /&gt;
&lt;br /&gt;
==== PHP Round trip ====&lt;br /&gt;
Our primary target here is to write a small PHP page and get it rendered by the Apache web server. To render a page WAMP by default looks into the www folder of the WAMP install directory referred henceforth as WAMP_HOME for convenience. Fire up your primary text editor and create a page say first.php and save it in the WAMP_HOME/www/x/y folder, where x, y are folders (which you can create for organizing your scripts). Write the following in the script&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
   &amp;lt;title&amp;gt;Basic PHP Page&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
echo (&amp;quot;My first php snippet&amp;quot;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save this file and point your browser to http://localhost/x/y/first.php and you should be able to see the echo message. &lt;br /&gt;
&lt;br /&gt;
Primary things to note here are &amp;lt;pre&amp;gt;&lt;br /&gt;
1. It is strongly advised to start any PHP code by &amp;quot;&amp;lt;?php&amp;quot; and end with a &amp;quot;?&amp;gt;&amp;quot; tag. &lt;br /&gt;
2. To have a semicolon after each PHP statement.&lt;br /&gt;
3. The directory in which this script resides needs to be given in the URL. &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This completes our round trip. Now for the sake of learning either you can keep including new elements in this file or may create separate scripts and load them in the browser.&lt;br /&gt;
&lt;br /&gt;
==== PHP Variable declaration and Data types ====&lt;br /&gt;
For any programming we need to hold data. In PHP following are the ways in which you can define variables.&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;$variable_name = 0; &amp;lt;/li&amp;gt;&lt;br /&gt;
Note here we did not define what is the type of variable, whether integer or string that the variable should hold. This is referred to as dynamic scoping. &lt;br /&gt;
&amp;lt;li&amp;gt; the variable names should start with an alphabet and can contain alphanumeric characters and &amp;quot;_&amp;quot;&lt;br /&gt;
&amp;lt;li&amp;gt; Defining constants - &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt; define (&amp;quot;NAME_OF_THE_CONSTANT&amp;quot; , $value); &amp;lt;/source&amp;gt; &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Basic operators ====&lt;br /&gt;
The general operators are as below and explained.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
a.	+   e.g. 6 + 3, addition operator, answer is 9&lt;br /&gt;
b.	–   e.g. 6 - 3, subtraction operator, answer is 3&lt;br /&gt;
c.	/   e.g. 6 / 3, division operator, answer is 2&lt;br /&gt;
d.	*   e.g. 6 * 3, multiplication operator, answer is 18&lt;br /&gt;
e.	%   e.g. 6 % 3, modulus operator, answer is 0&lt;br /&gt;
f.	.   e.g. &#039;6&#039;.&#039;3&#039;, concatenation operator, gives string &#039;63&#039;&lt;br /&gt;
g.	+=   e.g. $x += 6, adds 6&lt;br /&gt;
h.	-=   e.g. $x -= 6, subtracts 6&lt;br /&gt;
i.	/=   e.g. $x /= 6, divides by 6&lt;br /&gt;
j.	%=   e.g. $x %= 6, modulus by 6&lt;br /&gt;
k.	.=   e.g. $x .= &#039;6&#039;, concats 6 to x&lt;br /&gt;
l.	&amp;lt;   e.g. $x &amp;lt; $y, evaluates to true if $x is &amp;lt; $y&lt;br /&gt;
m.	&amp;gt;   e.g. $x &amp;gt; $y, evaluates to true if $x is &amp;gt; $y&lt;br /&gt;
n.	==  e.g. $x == $y, evaluates to true if $x is equal by value to $y&lt;br /&gt;
o.	!=  e.g. $x != $y, evaluates to true if $x is not equal to $y&lt;br /&gt;
p.	===   e.g. $x === $y, evaluates to true if $x is and $y is identical i.e both of same type both value and reference&lt;br /&gt;
q.	&amp;gt;=  e.g. $x &amp;gt;= $y, evaluates to true if $x is &amp;gt;= $y&lt;br /&gt;
r.	&amp;lt;=  e.g. $x &amp;lt;= $y, evaluates to true if $x is &amp;lt;= $y&lt;br /&gt;
s.	&amp;amp;&amp;amp;  e.g. ($x == 2 &amp;amp;&amp;amp; $y == 3) , evaluates to true if $x equals 2 and $y equals 3&lt;br /&gt;
t.	||  e.g. ($x == 2 || $y == 3) , evaluates to true if either $x equals 2 or $y equals 3&lt;br /&gt;
u.	xor e.g. ($x == 2 xor $y == 3) , evaluates to true if either $x equals 2 or $y equals 3 but not both&lt;br /&gt;
v.	++  e.g. $x++, increments $x&lt;br /&gt;
w.	–-  e.g. $x--, decrements $x&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Defining array Structures ====&lt;br /&gt;
&#039;&#039;&#039;Ways of declaring arrays&#039;&#039;&#039; &lt;br /&gt;
&amp;lt;br&amp;gt; Suppose we want many variables, we could have done in the way declaring variables as above, however, that is not elegant, for suppose u want a 100 variables; declaring arrays come to the rescue. Note that index in PHP starts from 0.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$my_guitar_heroes = array (&amp;quot;Hendrix&amp;quot;, &amp;quot;Schenker&amp;quot;, &amp;quot;Gilmour&amp;quot;, &amp;quot;to_name_a_few!&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$my_guitar_heroes [] = &amp;quot;Hendrix&amp;quot;;&lt;br /&gt;
$my_guitar_heroes [] = &amp;quot;Schenker&amp;quot;;&lt;br /&gt;
$my_guitar_heroes [] = &amp;quot;Gilmour&amp;quot;;&lt;br /&gt;
$my_guitar_heroes [] = &amp;quot;to_name_a_few!&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here PHP automatically assigns the index.&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$my_guitar_heroes [0] = &amp;quot;Hendrix&amp;quot;;&lt;br /&gt;
$my_guitar_heroes [10000] = &amp;quot;Mainak&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here in I just knew the first element and the 10,001st element and that&amp;amp;apost;s me!&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
a combination of the above means&lt;br /&gt;
&lt;br /&gt;
Or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Set the elements at positions 1 through 9999 to the value, &amp;quot;to be decided&amp;quot;.&lt;br /&gt;
$my_guitar_heroes  = array_fill( 1, 9999, &amp;quot;to be decided&amp;quot; ); &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Accessing the arrays&#039;&#039;&#039; &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
print $my_guitar_heroes[2]; //Access the 2nd element&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Access the last element (Note that the element positions are numbered zero to &lt;br /&gt;
// [number of elements] minus one.)&lt;br /&gt;
$my_guitar_heroes[count($my_guitar_heroes)-1]; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Access the last element using a function call.&lt;br /&gt;
end($my_guitar_heroes); &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Iterating over the element of an array&#039;&#039;&#039; &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
foreach ( $my_guitar_heroes as $temp) {&lt;br /&gt;
  print &amp;quot;$temp&amp;lt;br /&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Control expressions ====&lt;br /&gt;
To execute a statement of collection of statements over and over, we use Control expressions. The  following are general syntax of the control structures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;if statements&#039;&#039;&#039;&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
if( $x &amp;gt; 0) {	&lt;br /&gt;
 print(&amp;quot;$x is positive&amp;quot;);&lt;br /&gt;
}  else if( $x &amp;lt; 0 ) {	&lt;br /&gt;
 print(&amp;quot;$x is negative&amp;quot;);&lt;br /&gt;
} else {&lt;br /&gt;
 print(&amp;quot;$x is 0&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;for loop&#039;&#039;&#039;&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
for ( $x=1; $x&amp;lt;= 10; $x++ ) {&lt;br /&gt;
 print &amp;quot;$x&amp;lt;BR/&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;while loop&#039;&#039;&#039;&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$x = 1&lt;br /&gt;
while ( $x &amp;lt;= 10 ) {&lt;br /&gt;
 print &amp;quot;$x&amp;lt;BR/&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;do while loop&#039;&#039;&#039;&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$x = 1;&lt;br /&gt;
do {&lt;br /&gt;
 print &amp;quot;$x&amp;lt;BR/&amp;gt;&amp;quot;;&lt;br /&gt;
 $x++;&lt;br /&gt;
}while($x &amp;lt;= 10);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Defining functions ====&lt;br /&gt;
Code which is duplicated at many places are best placed in a function. Following are the ways of describing the function.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
function name_of_the_function( $arguments, $size=&#039;default_values_if_any&#039; ) {&lt;br /&gt;
  print &amp;quot;here goes in the code&amp;quot;; &lt;br /&gt;
  return &amp;quot;this value is returned, return statement is optional&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The arguments are passed by value. If they are to be passed by reference then an argument is prefixed by &amp;quot;&amp;amp;&amp;quot; as below&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
function name_of_the_function( &amp;amp;$arguments, $size=&#039;default_values_if_any&#039; ) {&lt;br /&gt;
  print &amp;quot;here goes in the code&amp;quot;; &lt;br /&gt;
  return &amp;quot;this value is returned, return statement is optional&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Scope of a variables defined within a function is valid within the function only. &lt;br /&gt;
&lt;br /&gt;
Calling a function&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;$x = add(5, 3);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Debugging ====&lt;br /&gt;
&#039;&#039;&#039;Basic printing options&#039;&#039;&#039; &amp;lt;br/&amp;gt;&lt;br /&gt;
A basic way to debug is to print the value of the variable. The following basic statments acheives that&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;echo &amp;quot;if double quotes are used then dollar variables are resolved&amp;quot;;&lt;br /&gt;
&amp;lt;li&amp;gt;echo &#039;if single quote are used then dollar variables are not resolved&#039;;&lt;br /&gt;
&amp;lt;li&amp;gt;print &amp;quot;another way to print&amp;quot;;&lt;br /&gt;
&amp;lt;li&amp;gt;nl2br(&amp;quot;any new line characters like \n get automatically resolved to HTML line breaks&amp;quot;);&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apart from these the log files are very helpful and can be found in the WAMP_HOME/logs directory.&lt;br /&gt;
&lt;br /&gt;
==== Handling forms ====&lt;br /&gt;
PHP does not change any HTML structure, thus any syntax of HTML remains the same. The part that PHP plays is making any part dynamic for e.g the action attribute of a form can be coded as action=&amp;lt;?php my_own_action(); ?&amp;gt; so that it is dynamically generated. The part where PHP kicks in is after the form is submitted, to say obtain the values of the form fields, set cookies etc. For this super global variables are used which are always available to PHP code. Some of these are  &lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;$_GET - get the data from a GET request&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;$_POST - get the data from a POST request&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;$_REQUEST - get the request&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;$_COOKIE - obtain the cookies from the browser&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;$_SESSION - obtain the session&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All of these are arrays and behave accordingly.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[Category:Templates]]&lt;/div&gt;</summary>
		<author><name>Ch00seLife</name></author>
	</entry>
</feed>