<?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=Drewgg</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=Drewgg"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/Drewgg"/>
	<updated>2026-05-24T19:53:30Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:Upgrading_a_Joomla_1.5_template_to_Joomla_2.5&amp;diff=68063</id>
		<title>Archived:Upgrading a Joomla 1.5 template to Joomla 2.5</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:Upgrading_a_Joomla_1.5_template_to_Joomla_2.5&amp;diff=68063"/>
		<updated>2012-06-28T14:00:03Z</updated>

		<summary type="html">&lt;p&gt;Drewgg: changed typo in code: type=&amp;quot; to type=&amp;quot;&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{RightTOC}}&lt;br /&gt;
This page provides feedback on the process of upgrading or converting a Joomla 1.5 template for use with Joomla 1.6 and later versions from those who have already attempted it. This is intended to be a living document that can be added to as more experience is gained and is likely to be reorganised periodically. If you have encountered a problem when upgrading a template, or if you have any information that you think will help smooth the way for others who will follow then please add your comments initially on the Talk page. We will then collate the information and incorporate it into this page.&lt;br /&gt;
&lt;br /&gt;
[[User:Chris Davenport|Chris Davenport]] prepared [http://www.slideshare.net/chrisdavenport/template-changes-for-joomla-16 slides for a presentation at the JoomlaDay UK 2010 event] which explain the changes in templates for Joomla! 1.6.&lt;br /&gt;
&lt;br /&gt;
== Template Manifest File ==&lt;br /&gt;
There are important changes to the &#039;&#039;templateDetails.xml&#039;&#039; file:&lt;br /&gt;
# Add the new 1.6 Doctype&lt;br /&gt;
# Change the &#039;&#039;&amp;lt;install&amp;gt;&#039;&#039; tag to &#039;&#039;&amp;lt;extension&amp;gt;&#039;&#039; as shown below.&lt;br /&gt;
&amp;lt;pre&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;!DOCTYPE install PUBLIC &amp;quot;-//Joomla! 1.6//DTD template 1.0//EN&amp;quot; &amp;quot;http://www.joomla.org/xml/dtd/1.6/template-install.dtd&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;extension version=&amp;quot;1.7&amp;quot; type=&amp;quot;template&amp;quot; client=&amp;quot;site&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Notice the additional new &#039;&#039;client&#039;&#039; attribute which is set to &#039;&#039;site&#039;&#039; for a front-facing template and &#039;&#039;administrator&#039;&#039; for an back-end template.&lt;br /&gt;
&lt;br /&gt;
Be sure to change the closing tag from &#039;&#039;&amp;lt;/install&amp;gt;&#039;&#039; to &#039;&#039;&amp;lt;/extension&amp;gt;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Template Parameters ===&lt;br /&gt;
In Joomla! 1.5, 1.6 and later versions, the template parameters are defined in templateDetails.xml. &lt;br /&gt;
&lt;br /&gt;
Whereas in 1.5 parameters are defined as part of the &amp;lt;code&amp;gt;&amp;lt;params&amp;gt;&amp;lt;/code&amp;gt; section, and each parameter is defined as a &amp;lt;code&amp;gt;&amp;lt;param&amp;gt;&amp;lt;/code&amp;gt;, in 1.6 and later template parameters are contained in the &amp;lt;code&amp;gt;&amp;lt;config&amp;gt;&amp;lt;/code&amp;gt; section and treated as a &amp;lt;code&amp;gt;&amp;lt;field&amp;gt;&amp;lt;/code&amp;gt; nested within the &amp;lt;code&amp;gt;&amp;lt;fieldset&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;fields&amp;gt;&amp;lt;/code&amp;gt; tags, as illustrated below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;config&amp;gt;&lt;br /&gt;
    &amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;fieldset name=&amp;quot;basic&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field name=&amp;quot;&amp;quot; type=&amp;quot;&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;&amp;quot; description=&amp;quot;&amp;quot;&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;option value=&amp;quot;0&amp;quot;&amp;gt;Off&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field name=&amp;quot;&amp;quot; type=&amp;quot;&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;e&amp;quot; description=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
    &amp;lt;/fields&amp;gt;&lt;br /&gt;
&amp;lt;/config&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;fieldset name=&amp;quot;basic&amp;quot;&amp;gt;&amp;lt;/code&amp;gt; wraps the parameters in a grouping element. Using &#039;&#039;name=&amp;quot;basic&amp;quot;&#039;&#039; labels that element as &amp;quot;Basic Options&amp;quot; and &#039;&#039;name=&amp;quot;advanced&amp;quot;&#039;&#039; labels it as &amp;quot;Advanced Options&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;name&#039;&#039;, &#039;&#039;type&#039;&#039;, &#039;&#039;default&#039;&#039;, &#039;&#039;label&#039;&#039; and &#039;&#039;description&#039;&#039; attributes still apply.&lt;br /&gt;
&lt;br /&gt;
Outside of the main template files, you can access these parameters using the JApplication class. Previously, the values of the template parameters were stored in a plain text .ini file. In order to access those values outside of the template you needed to read the ini file and load the data into a JRegistry or JParameters object. Now, the values are stored in the database with other template information. We can load the params by passing the true variable to the getTemplate method of the JApplication object. It can be accessed like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$app		=&amp;amp; JFactory::getApplication();&lt;br /&gt;
$template	= $app-&amp;gt;getTemplate(true);&lt;br /&gt;
$params		= $template-&amp;gt;params;&lt;br /&gt;
$variable	= $params-&amp;gt;get(&#039;variable&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow you to access the template params in your layout overrides for other components, and modules.&lt;br /&gt;
&lt;br /&gt;
== Objects and Methods ==&lt;br /&gt;
=== Sitename ===&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;?php echo $mainframe-&amp;gt;getCfg(&#039;sitename&#039;);?&amp;gt;&amp;lt;/code&amp;gt; is now &amp;lt;code&amp;gt;$app-&amp;gt;getCfg(&#039;sitename&#039;);&amp;lt;/code&amp;gt; Where &amp;lt;code&amp;gt;$app = JFactory::getApplication();&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Error Codes ===&lt;br /&gt;
* &amp;lt;code&amp;gt;$this-&amp;gt;error-&amp;gt;code&amp;lt;/code&amp;gt; is replaced by &amp;lt;code&amp;gt;$this-&amp;gt;error-&amp;gt;getCode();&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;$this-&amp;gt;error-&amp;gt;message&amp;lt;/code&amp;gt; is replaced by &amp;lt;code&amp;gt;$this-&amp;gt;error-&amp;gt;getMessage();&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Discovery ==&lt;br /&gt;
In some cases your converted template may not be shown in the Template Manager even though all coding appears to be correct. Verify that your template files are installed in the &#039;&#039;/templates&#039;&#039; directory. Then run the Discover process as follows.&lt;br /&gt;
# Go to Administrator &amp;gt; Extensions &amp;gt; Extension Manager &amp;gt; Discover&lt;br /&gt;
# Click the Discover icon.&lt;br /&gt;
# If your template appears on the list, select it and then click the Install icon.&lt;br /&gt;
&lt;br /&gt;
== Layout Overrides ==&lt;br /&gt;
=== com_content ===&lt;br /&gt;
If you have used the Beez overrides, or code derived from the Beez overrides, in your 1.5 template, you may encounter a &#039;&#039;JHtml::icon not supported. File not found.&#039;&#039; error when migrating the template to Joomla 1.6 and later. To fix this, simply add the following statement near the top of the template html/com_content/article/default.php file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JHtml::addIncludePath( JPATH_COMPONENT . &#039;/helpers&#039; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Alternate Method Using a Version 2.5 Template==&lt;br /&gt;
Start with a basic template that works with a current version of Joomla. For this example, use the Atomic template that is supplied with Joomla 2.5.&lt;br /&gt;
&lt;br /&gt;
# Copy the entire &#039;&#039;/templates/atomic&#039;&#039; folder to a new folder in the &#039;&#039;/templates&#039;&#039; directory.&lt;br /&gt;
# Rename this new folder. For instance, you might call it &#039;&#039;mysitename-atomic&#039;&#039; to designate it as the custom template for this site and adding the reminder that it was derived from the &#039;&#039;atomic&#039;&#039; template.&lt;br /&gt;
# In the new template&#039;s &#039;&#039;index.php&#039;&#039; file, delete everything between the &#039;&#039;&amp;lt;body&amp;gt; &amp;lt;/body&amp;gt;&#039;&#039; tags.&lt;br /&gt;
# Copy and paste everything within the &#039;&#039;&amp;lt;body&amp;gt; &amp;lt;/body&amp;gt;&#039;&#039; tags from your version 1.5 template to the body of the new template&#039;s &#039;&#039;index.php&#039;&#039; file.&lt;br /&gt;
# Delete or rename the &#039;&#039;template.css&#039;&#039; file copied from the Atomic template.&lt;br /&gt;
# Copy the &#039;&#039;template.css&#039;&#039; file from the old version 1.5 template.&lt;br /&gt;
# Update the &#039;&#039;templateDetails.xml&#039;&#039; file in the revised template.&lt;br /&gt;
## Change the &#039;&#039;&amp;lt;name&amp;gt;&#039;&#039; entry to match the name of the template folder. It is case-sensitive. If the folder is &#039;&#039;/templates/mysitename-atomic&#039;&#039;, the entry in the &#039;&#039;templateDetails.xml&#039;&#039; file will be &#039;&#039;&amp;lt;name&amp;gt;mysitename-atomic&amp;lt;/name&amp;gt;&#039;&#039;.&lt;br /&gt;
## Replace the &#039;&#039;&amp;lt;positions&amp;gt;&#039;&#039; section of the file so that they match the positions used in the &#039;&#039;index.php&#039;&#039; file.&lt;br /&gt;
## Change the other elements as necessary. For instance, you might want to modify the creation date and version number.&lt;br /&gt;
# Delete images in the &#039;&#039;/template/image&#039;&#039; file and add your images.&lt;br /&gt;
# Delete the lines in the &#039;&#039;&amp;lt;head&amp;gt;&#039;&#039; section of the &#039;&#039;index.php&#039;&#039; file that load CSS and Javascript files that are not needed.&lt;br /&gt;
==Template Root Directory Considerations==&lt;br /&gt;
Compare the files in the root directory of the new template to old template&#039;s root directory files. It may be necessary to copy a few of the old files to the new template.&lt;br /&gt;
&lt;br /&gt;
For example, copy the old favicon.ico file to the new template&#039;s root directory.&lt;br /&gt;
&lt;br /&gt;
Remove the &#039;&#039;/html&#039;&#039; directory that was in the donor template. Copy the &#039;&#039;/html&#039;&#039; directory from your old template&#039;s files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Joomla! 1.6]]&lt;br /&gt;
[[Category:Template Development]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Drewgg</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Talk:Creating_a_custom_form_field_type&amp;diff=67421</id>
		<title>Talk:Creating a custom form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Talk:Creating_a_custom_form_field_type&amp;diff=67421"/>
		<updated>2012-05-30T17:14:49Z</updated>

		<summary type="html">&lt;p&gt;Drewgg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Set up base class is not neccessary. I have implemented custom list field using JFormField as parent class.&lt;br /&gt;
No need for class like specified in step 2, just write our getInput() or getOptions().&lt;br /&gt;
&lt;br /&gt;
- Mrs.siam&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When creating a custom field for a front-end component ( /administrator/components/&amp;lt;component&amp;gt;/views/&amp;lt;view&amp;gt;/tmpl/&amp;lt;layout&amp;gt;.xml ) I was unable to use the custom field until I added the field path to my &amp;lt;fieldset&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;fieldset addfieldpath=&amp;quot;/administrator/components/&amp;lt;component&amp;gt;/models/fields&amp;quot; ...&amp;gt;&lt;br /&gt;
	&amp;lt;field name=&amp;quot;foo&amp;quot; type=&amp;quot;customFieldName&amp;quot; ... /&amp;gt;&lt;br /&gt;
&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I don&#039;t know where else this would be required, ie: if it&#039;s required when using /administrator/components/&amp;lt;component&amp;gt;/models/forms/&amp;lt;whatever&amp;gt;.xml.&lt;br /&gt;
&lt;br /&gt;
I also don&#039;t know if there is an alternative to using addfieldpath.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[User:Drewgg|Drewgg]] 12:14, 30 May 2012 (CDT) Drewgg&lt;/div&gt;</summary>
		<author><name>Drewgg</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Talk:Creating_a_custom_form_field_type&amp;diff=67420</id>
		<title>Talk:Creating a custom form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Talk:Creating_a_custom_form_field_type&amp;diff=67420"/>
		<updated>2012-05-30T17:14:01Z</updated>

		<summary type="html">&lt;p&gt;Drewgg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Set up base class is not neccessary. I have implemented custom list field using JFormField as parent class.&lt;br /&gt;
No need for class like specified in step 2, just write our getInput() or getOptions().&lt;br /&gt;
&lt;br /&gt;
- unknown author&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When creating a custom field for a front-end component ( /administrator/components/&amp;lt;component&amp;gt;/views/&amp;lt;view&amp;gt;/tmpl/&amp;lt;layout&amp;gt;.xml ) I was unable to use the custom field until I added the field path to my &amp;lt;fieldset&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;fieldset addfieldpath=&amp;quot;/administrator/components/&amp;lt;component&amp;gt;/models/fields&amp;quot; ...&amp;gt;&lt;br /&gt;
	&amp;lt;field name=&amp;quot;foo&amp;quot; type=&amp;quot;customFieldName&amp;quot; ... /&amp;gt;&lt;br /&gt;
&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I don&#039;t know where else this would be required, ie: if it&#039;s required when using /administrator/components/&amp;lt;component&amp;gt;/models/forms/&amp;lt;whatever&amp;gt;.xml.&lt;br /&gt;
&lt;br /&gt;
I also don&#039;t know if there is an alternative to using addfieldpath.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[User:Drewgg|Drewgg]] 12:14, 30 May 2012 (CDT) Drewgg&lt;/div&gt;</summary>
		<author><name>Drewgg</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Creating_a_custom_form_field_type&amp;diff=67419</id>
		<title>Creating a custom form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Creating_a_custom_form_field_type&amp;diff=67419"/>
		<updated>2012-05-30T17:02:05Z</updated>

		<summary type="html">&lt;p&gt;Drewgg: /* Using the custom field type */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[JForm]], a feature introduced in Joomla 1.6, lets you easily create HTML forms (&amp;lt;code&amp;gt;&amp;lt;form&amp;gt;&amp;lt;/code&amp;gt;). Forms created using JForm consist of [[Form field|form fields]], implemented as [[JFormField|JFormFields]]. There is a JFormField for each different field type you can find in a form, such as a text field type and a date field type. JForm supports a large selection of standard field types. For a full list, see [[Standard form field types]].&lt;br /&gt;
&lt;br /&gt;
Joomla 1.6 makes it possible to extend standard field types or define your own. For example, if your component manages phone book entries, you might want to define a form field type that outputs a select list of cities. There are several advantages to defining a custom form field type:&lt;br /&gt;
&lt;br /&gt;
* You will be able to mix standard field types with your custom field type in a JForm-based form.&lt;br /&gt;
* You will eventually have a reusable code package that can be used easily throughout your code.&lt;br /&gt;
* Extensions that collaborate with your extension will be able to create form fields without meddling with your database tables and other internals.&lt;br /&gt;
&lt;br /&gt;
== Form field type class requirements ==&lt;br /&gt;
&lt;br /&gt;
A form field type is defined in a [[wikipedia:Class (computer programming)|class]] that must be a (not necessarily direct) subclass of JFormField. To work correctly, the class must define at least two methods:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;public function getLabel()&amp;lt;/code&amp;gt;&lt;br /&gt;
*: This function will be called to create the label that belongs to your field and must return a HTML string containing it. Since JFormField defines a ready-to-use &amp;lt;code&amp;gt;getLabel()&amp;lt;/code&amp;gt; implementation, custom form field types usually do not define their own &amp;lt;code&amp;gt;getLabel()&amp;lt;/code&amp;gt;. If you leave it out, the inherited method of creating labels will be used. It is recommended to leave out the &amp;lt;code&amp;gt;getLabel()&amp;lt;/code&amp;gt; method for consistency and speed unless you actually want to modify the label&#039;s HTML.&lt;br /&gt;
* &amp;lt;code&amp;gt;public function getInput()&amp;lt;/code&amp;gt;&lt;br /&gt;
*: This function will be called to create the field itself and must return a HTML string containing it. This is also where most of the processing usually happens. In our phone book City field example, this function will have to retrieve a list of available cities and return a HTML &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;/code&amp;gt; with the cities inserted as &amp;lt;code&amp;gt;&amp;lt;option&amp;gt;&amp;lt;/code&amp;gt;s.&lt;br /&gt;
&lt;br /&gt;
Inside your code, you will have to process the attributes set by the field&#039;s user in the XML form definition. Some of those attributes are accessible via protected member variables of JFormField. For example, the &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; attribute is available in your code as &amp;lt;code&amp;gt;$this-&amp;gt;name&amp;lt;/code&amp;gt;. Similarly, &amp;lt;code&amp;gt;label&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;description&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;multiple&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;class&amp;lt;/code&amp;gt; are also available as properties of &amp;lt;code&amp;gt;$this&amp;lt;/code&amp;gt;. Other parameters you might have defined can be accessed through the &amp;lt;code&amp;gt;$this-&amp;gt;element&amp;lt;/code&amp;gt; array: the attribute &amp;lt;code&amp;gt;size&amp;lt;/code&amp;gt; will be in &amp;lt;code&amp;gt;$this-&amp;gt;element[&#039;size&#039;]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Which class to subclass? ==&lt;br /&gt;
&lt;br /&gt;
For a form field type to be usable in JForm, it needs do be a subclass of JFormField. However, it does not have to be a direct child of that class: you can also subclass an existing (standard or custom) form field type and thereby inherit useful code.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;If your form field type is quite similar to an existing type,&#039;&#039;&#039; you should subclass that type. Especially if your form field type is a &#039;&#039;&#039;list&#039;&#039;&#039;, please subclass [[JFormFieldList]]. You only have to override &amp;lt;code&amp;gt;getOptions()&amp;lt;/code&amp;gt; method to return the options to be shown; the &amp;lt;code&amp;gt;getInput()&amp;lt;/code&amp;gt; method will convert those options to HTML.&lt;br /&gt;
&lt;br /&gt;
To subclass an existing type, for example JFormFieldList, load it by adding the following to after &amp;lt;code&amp;gt;jimport(&#039;joomla.form.formfield&#039;);&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.form.helper&#039;);&lt;br /&gt;
JFormHelper::loadFieldClass(&#039;list&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;If your form field type is unlike any existing type,&#039;&#039;&#039; subclass JFormField directly.&lt;br /&gt;
&lt;br /&gt;
== Location of files ==&lt;br /&gt;
&lt;br /&gt;
* The standard form field types are located in &amp;lt;code&amp;gt;joomla/libraries/joomla/form/fields/&amp;lt;/code&amp;gt;. You should not store custom fields there, nor should you have to use this path in your own code, but the standard types are usually good examples.&lt;br /&gt;
* The custom field types that belong to your component are usually located in &amp;lt;code&amp;gt;administrator/components/&amp;lt;name of your component&amp;gt;/models/fields&amp;lt;/code&amp;gt;. You can specify this or another path in your code:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;JForm::addFieldPath(JPATH_COMPONENT . DS . &#039;models&#039; . DS . &#039;fields&#039;);&amp;lt;/source&amp;gt;&lt;br /&gt;
* The XML files that define forms are usually located in &amp;lt;code&amp;gt;administrator/components/&amp;lt;name of your component&amp;gt;/models/forms&amp;lt;/code&amp;gt;. Use something like the following snippet to specify a path to your forms:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;JForm::addFormPath(JPATH_COMPONENT . DS . &#039;models&#039; . DS . &#039;forms&#039;);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Naming conventions and skeleton ==&lt;br /&gt;
&lt;br /&gt;
In this section, &amp;lt;ComponentName&amp;gt; represents the camel-cased name of your component and &amp;lt;TypeName&amp;gt; represents the camel-cased name of your form field type. The field&#039;s class should be placed in &amp;lt;code&amp;gt;administrator/components/&amp;lt;name of your component&amp;gt;/models/fields/&amp;lt;name of your field&amp;gt;.php&amp;lt;/code&amp;gt;, and look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
// Check to ensure this file is included in Joomla!&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
jimport(&#039;joomla.form.formfield&#039;);&lt;br /&gt;
&lt;br /&gt;
// The class name must always be the same as the filename (in camel case)&lt;br /&gt;
class JFormField&amp;lt;FieldName&amp;gt; extends JFormField {&lt;br /&gt;
&lt;br /&gt;
	//The field class must know its own type through the variable $type.&lt;br /&gt;
	protected $type = &#039;&amp;lt;FieldName&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
	public function getLabel() {&lt;br /&gt;
		// code that returns HTML that will be shown as the label&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public function getInput() {&lt;br /&gt;
		// code that returns HTML that will be shown as the form field&lt;br /&gt;
	}&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Grouping custom field types ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning: this information is partially incorrect and needs to be improved.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Custom field types can be grouped by using an underscore in the field name. A field class with a name for example like &amp;quot;JFormFieldMy_randomField&amp;quot; must be stored in &amp;lt;code&amp;gt;administrator/components/&amp;lt;name of your component&amp;gt;/models/fields/my/randomField.php&amp;lt;/code&amp;gt;. We can prefix our form field names with some group name, then we put an underscore and then a name of a field.&lt;br /&gt;
&lt;br /&gt;
== An example custom field type ==&lt;br /&gt;
&lt;br /&gt;
Suppose you&#039;re working on your component named &#039;&#039;com_phonebook&#039;&#039; and you want to define a field that contains cities. Create the file &amp;lt;code&amp;gt;administrator/components/com_phonebook/models/fields/city.php&amp;lt;/code&amp;gt; and write something similar to the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
// Check to ensure this file is included in Joomla!&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
jimport(&#039;joomla.form.formfield&#039;);&lt;br /&gt;
&lt;br /&gt;
class JFormFieldCity extends JFormField {&lt;br /&gt;
	&lt;br /&gt;
	protected $type = &#039;City&#039;;&lt;br /&gt;
&lt;br /&gt;
	// getLabel() left out&lt;br /&gt;
&lt;br /&gt;
	public function getInput() {&lt;br /&gt;
		return &#039;&amp;lt;select id=&amp;quot;&#039;.$this-&amp;gt;id.&#039;&amp;quot; name=&amp;quot;&#039;.$this-&amp;gt;name.&#039;&amp;quot;&amp;gt;&#039;.&lt;br /&gt;
		       &#039;&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;New York&amp;lt;/option&amp;gt;&#039;.&lt;br /&gt;
		       &#039;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;Chicago&amp;lt;/option&amp;gt;&#039;.&lt;br /&gt;
		       &#039;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;San Francisco&amp;lt;/option&amp;gt;&#039;.&lt;br /&gt;
		       &#039;&amp;lt;/select&amp;gt;&#039;;&lt;br /&gt;
	}&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using the custom field type ===&lt;br /&gt;
&lt;br /&gt;
To use the field type City, we need to update the XML file that contains the form fields. Open your XML file located in &amp;lt;code&amp;gt;administrator/components/com_phonebook/models/forms&amp;lt;/code&amp;gt; and add the field in the usual way:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;title&amp;quot; type=&amp;quot;City&amp;quot; label=&amp;quot;JGLOBAL_TITLE&amp;quot;&lt;br /&gt;
	description=&amp;quot;JFIELD_TITLE_DESC&amp;quot;&lt;br /&gt;
	required=&amp;quot;true&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
The type name is cAsE-sEnSiTiVe.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In addition, you may need to add the field path to the parent &amp;lt;fieldset&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;fieldset addfieldpath=&amp;quot;/administrator/components/&amp;lt;component name&amp;gt;/models/fields&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Overriding &amp;lt;code&amp;gt;getLabel()&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
As mentioned in the section [[#Form field type class requirements|Form field type class requirements]], custom form field types usually do not define their own &amp;lt;code&amp;gt;getLabel()&amp;lt;/code&amp;gt;. If you do want to create a custom label, you can still make use of the &amp;lt;code&amp;gt;getLabel()&amp;lt;/code&amp;gt; that every field type class inherits from JFormField, for example by defining it as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;public function getLabel() {&lt;br /&gt;
     return &#039;&amp;lt;span style=&amp;quot;text-decoration: underline;&amp;quot;&amp;gt;&#039; . parent::getLabel() . &#039;&amp;lt;/span&amp;gt;&#039;;&lt;br /&gt;
} &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code will underline your form labels. (Please note that if your goal is to underline form labels, using [[CSS]] is the preferred way.)&lt;br /&gt;
&lt;br /&gt;
If you want to do something completely different, you can of course also override it completely:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;public function getLabel() {&lt;br /&gt;
	// Initialize variables.&lt;br /&gt;
	$label = &#039;&#039;;&lt;br /&gt;
	$replace = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
	// Get the label text from the XML element, defaulting to the element name.&lt;br /&gt;
	$text = $this-&amp;gt;element[&#039;label&#039;] ? (string) $this-&amp;gt;element[&#039;label&#039;] : (string) $this-&amp;gt;element[&#039;name&#039;];&lt;br /&gt;
&lt;br /&gt;
	// Build the class for the label.&lt;br /&gt;
	$class = !empty($this-&amp;gt;description) ? &#039;hasTip&#039; : &#039;&#039;;&lt;br /&gt;
	$class = $this-&amp;gt;required == true ? $class.&#039; required&#039; : $class;&lt;br /&gt;
		&lt;br /&gt;
	// Add replace checkbox&lt;br /&gt;
	$replace = &#039;&amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;update[&#039;.$this-&amp;gt;name.&#039;]&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&#039;;&lt;br /&gt;
		&lt;br /&gt;
	// Add the opening label tag and main attributes attributes.&lt;br /&gt;
	$label .= &#039;&amp;lt;label id=&amp;quot;&#039;.$this-&amp;gt;id.&#039;-lbl&amp;quot; for=&amp;quot;&#039;.$this-&amp;gt;id.&#039;&amp;quot; class=&amp;quot;&#039;.$class.&#039;&amp;quot;&#039;;&lt;br /&gt;
&lt;br /&gt;
	// If a description is specified, use it to build a tooltip.&lt;br /&gt;
	if (!empty($this-&amp;gt;description)) {&lt;br /&gt;
		$label .= &#039; title=&amp;quot;&#039;.htmlspecialchars(trim(JText::_($text), &#039;:&#039;).&#039;::&#039; .&lt;br /&gt;
				JText::_($this-&amp;gt;description), ENT_COMPAT, &#039;UTF-8&#039;).&#039;&amp;quot;&#039;;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	// Add the label text and closing tag.&lt;br /&gt;
	$label .= &#039;&amp;gt;&#039;.$replace.JText::_($text).&#039;&amp;lt;/label&amp;gt;&#039;;&lt;br /&gt;
	&lt;br /&gt;
	return $label; &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example will add a checkbox before the label.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;[[Category:Development]][[Category:Form fields]][[Category:Joomla! 1.6]]&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Drewgg</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=API16:JHtml/date&amp;diff=65305</id>
		<title>API16:JHtml/date</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=API16:JHtml/date&amp;diff=65305"/>
		<updated>2012-03-02T21:32:02Z</updated>

		<summary type="html">&lt;p&gt;Drewgg: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
Returns formated date according to a given format and time zone.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;editsection&amp;quot; style=&amp;quot;font-size:76%;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;[[Description:JHtml/date|Edit Descripton]]&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Description:JHtml/date}}&lt;br /&gt;
&lt;br /&gt;
===Syntax===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;static date($input= &#039;now&#039;, $format=null, $tz=true)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Parameter Name&lt;br /&gt;
!Default Value&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
| $input&lt;br /&gt;
| &#039;now&#039;&lt;br /&gt;
|  String in a format accepted by strtotime(), defaults to &amp;quot;now&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
| $format&lt;br /&gt;
| null&lt;br /&gt;
|  format optional format for strftime &lt;br /&gt;
|-&lt;br /&gt;
| $tz&lt;br /&gt;
| true&lt;br /&gt;
|  Time zone to be used for the date. Special cases: boolean true for user setting, boolean false for server setting. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
string A date translated by the given format and time zone. &lt;br /&gt;
&lt;br /&gt;
===Defined in===&lt;br /&gt;
libraries/joomla/html/html.php&lt;br /&gt;
===Importing===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;jimport( &#039;joomla.html.html&#039; );&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Source Body===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
public static function date($input = &#039;now&#039;, $format = null, $tz = true)&lt;br /&gt;
{&lt;br /&gt;
        // Get some system objects.&lt;br /&gt;
        $config = JFactory::getConfig();&lt;br /&gt;
        $user   = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
        // UTC date converted to user time zone.&lt;br /&gt;
        if ($tz === true)&lt;br /&gt;
        {&lt;br /&gt;
                // Get a date object based on UTC.&lt;br /&gt;
                $date = JFactory::getDate($input, &#039;UTC&#039;);&lt;br /&gt;
&lt;br /&gt;
                // Set the correct time zone based on the user configuration.&lt;br /&gt;
                $date-&amp;gt;setOffset($user-&amp;gt;getParam(&#039;timezone&#039;, $config-&amp;gt;getValue(&#039;config.offset&#039;)));&lt;br /&gt;
        }&lt;br /&gt;
        // UTC date converted to server time zone.&lt;br /&gt;
        elseif ($tz === false)&lt;br /&gt;
        {&lt;br /&gt;
                // Get a date object based on UTC.&lt;br /&gt;
                $date = JFactory::getDate($input, &#039;UTC&#039;);&lt;br /&gt;
&lt;br /&gt;
                // Set the correct time zone based on the server configuration.&lt;br /&gt;
                $date-&amp;gt;setOffset($config-&amp;gt;getValue(&#039;config.offset&#039;));&lt;br /&gt;
        }&lt;br /&gt;
        // No date conversion.&lt;br /&gt;
        elseif ($tz === null)&lt;br /&gt;
        {&lt;br /&gt;
                $date = JFactory::getDate($input);&lt;br /&gt;
        }&lt;br /&gt;
        // UTC date converted to given time zone.&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
                // Get a date object based on UTC.&lt;br /&gt;
                $date = JFactory::getDate($input, &#039;UTC&#039;);&lt;br /&gt;
&lt;br /&gt;
                // Set the correct time zone based on the server configuration.&lt;br /&gt;
                $date-&amp;gt;setOffset($tz);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        // If no format is given use the default locale based format.&lt;br /&gt;
        if (!$format) {&lt;br /&gt;
                $format = JText::_(&#039;DATE_FORMAT_LC1&#039;);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return $date-&amp;gt;toFormat($format);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;editsection&amp;quot; style=&amp;quot;font-size:76%;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;[[SeeAlso:JHtml/date|Edit See Also]]&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
{{SeeAlso:JHtml/date}}&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&amp;lt;CodeExamplesForm /&amp;gt;&lt;br /&gt;
&amp;lt;dpl&amp;gt;&lt;br /&gt;
 noresultsheader=\n&lt;br /&gt;
 category=date&lt;br /&gt;
 category=JHtml&lt;br /&gt;
 category=CodeExample&lt;br /&gt;
 category=MethodExample&lt;br /&gt;
 include=*&lt;br /&gt;
 format= ,,,&lt;br /&gt;
&amp;lt;/dpl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Server Timezone: &amp;quot;New York&amp;quot; (-0500 GMT)&lt;br /&gt;
// User Timeszone: &amp;quot;Los Angeles&amp;quot; (-0800 GMT)&lt;br /&gt;
&lt;br /&gt;
jimport( &#039;joomla.html.html&#039; );&lt;br /&gt;
&lt;br /&gt;
$sqlGmtTimestamp = &amp;quot;2012-03-01 20:00:00&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo JHtml::date($sqlGmtTimestamp , &#039;D F n, Y g:i a&#039;);        // Fri March 1, 2012 12:00 pm&lt;br /&gt;
echo JHtml::date($sqlGmtTimestamp , &#039;D F n, Y g:i a&#039;, true);  // Fri March 1, 2012 12:00 pm&lt;br /&gt;
echo JHtml::date($sqlGmtTimestamp , &#039;D F n, Y g:i a&#039;, false); // Fri March 1, 2012 3:00 pm&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Drewgg</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=API16:JHtml/date&amp;diff=65304</id>
		<title>API16:JHtml/date</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=API16:JHtml/date&amp;diff=65304"/>
		<updated>2012-03-02T21:31:38Z</updated>

		<summary type="html">&lt;p&gt;Drewgg: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
Returns formated date according to a given format and time zone.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;editsection&amp;quot; style=&amp;quot;font-size:76%;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;[[Description:JHtml/date|Edit Descripton]]&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Description:JHtml/date}}&lt;br /&gt;
&lt;br /&gt;
===Syntax===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;static date($input= &#039;now&#039;, $format=null, $tz=true)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Parameter Name&lt;br /&gt;
!Default Value&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
| $input&lt;br /&gt;
| &#039;now&#039;&lt;br /&gt;
|  String in a format accepted by strtotime(), defaults to &amp;quot;now&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
| $format&lt;br /&gt;
| null&lt;br /&gt;
|  format optional format for strftime &lt;br /&gt;
|-&lt;br /&gt;
| $tz&lt;br /&gt;
| true&lt;br /&gt;
|  Time zone to be used for the date. Special cases: boolean true for user setting, boolean false for server setting. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
string A date translated by the given format and time zone. &lt;br /&gt;
&lt;br /&gt;
===Defined in===&lt;br /&gt;
libraries/joomla/html/html.php&lt;br /&gt;
===Importing===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;jimport( &#039;joomla.html.html&#039; );&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Source Body===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
public static function date($input = &#039;now&#039;, $format = null, $tz = true)&lt;br /&gt;
{&lt;br /&gt;
        // Get some system objects.&lt;br /&gt;
        $config = JFactory::getConfig();&lt;br /&gt;
        $user   = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
        // UTC date converted to user time zone.&lt;br /&gt;
        if ($tz === true)&lt;br /&gt;
        {&lt;br /&gt;
                // Get a date object based on UTC.&lt;br /&gt;
                $date = JFactory::getDate($input, &#039;UTC&#039;);&lt;br /&gt;
&lt;br /&gt;
                // Set the correct time zone based on the user configuration.&lt;br /&gt;
                $date-&amp;gt;setOffset($user-&amp;gt;getParam(&#039;timezone&#039;, $config-&amp;gt;getValue(&#039;config.offset&#039;)));&lt;br /&gt;
        }&lt;br /&gt;
        // UTC date converted to server time zone.&lt;br /&gt;
        elseif ($tz === false)&lt;br /&gt;
        {&lt;br /&gt;
                // Get a date object based on UTC.&lt;br /&gt;
                $date = JFactory::getDate($input, &#039;UTC&#039;);&lt;br /&gt;
&lt;br /&gt;
                // Set the correct time zone based on the server configuration.&lt;br /&gt;
                $date-&amp;gt;setOffset($config-&amp;gt;getValue(&#039;config.offset&#039;));&lt;br /&gt;
        }&lt;br /&gt;
        // No date conversion.&lt;br /&gt;
        elseif ($tz === null)&lt;br /&gt;
        {&lt;br /&gt;
                $date = JFactory::getDate($input);&lt;br /&gt;
        }&lt;br /&gt;
        // UTC date converted to given time zone.&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
                // Get a date object based on UTC.&lt;br /&gt;
                $date = JFactory::getDate($input, &#039;UTC&#039;);&lt;br /&gt;
&lt;br /&gt;
                // Set the correct time zone based on the server configuration.&lt;br /&gt;
                $date-&amp;gt;setOffset($tz);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        // If no format is given use the default locale based format.&lt;br /&gt;
        if (!$format) {&lt;br /&gt;
                $format = JText::_(&#039;DATE_FORMAT_LC1&#039;);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return $date-&amp;gt;toFormat($format);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;editsection&amp;quot; style=&amp;quot;font-size:76%;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;[[SeeAlso:JHtml/date|Edit See Also]]&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;br /&gt;
{{SeeAlso:JHtml/date}}&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&amp;lt;CodeExamplesForm /&amp;gt;&lt;br /&gt;
&amp;lt;dpl&amp;gt;&lt;br /&gt;
 noresultsheader=\n&lt;br /&gt;
 category=date&lt;br /&gt;
 category=JHtml&lt;br /&gt;
 category=CodeExample&lt;br /&gt;
 category=MethodExample&lt;br /&gt;
 include=*&lt;br /&gt;
 format= ,,,&lt;br /&gt;
&amp;lt;/dpl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Server Timezone: &amp;quot;New York&amp;quot; (-0500 GMT)&lt;br /&gt;
// User Timeszone: &amp;quot;Los Angeles&amp;quot; (-0800 GMT)&lt;br /&gt;
&lt;br /&gt;
jimport( &#039;joomla.html.html&#039; );&lt;br /&gt;
&lt;br /&gt;
$sqlGmtTimestamp = &amp;quot;2012-03-01 20:00:00&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo JHtml::date(sqlGmtTimestamp , &#039;D F n, Y g:i a&#039;);        // Fri March 1, 2012 12:00 pm&lt;br /&gt;
echo JHtml::date(sqlGmtTimestamp , &#039;D F n, Y g:i a&#039;, true);  // Fri March 1, 2012 12:00 pm&lt;br /&gt;
echo JHtml::date(sqlGmtTimestamp , &#039;D F n, Y g:i a&#039;, false); // Fri March 1, 2012 3:00 pm&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Drewgg</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:Adapting_a_Joomla_1.5_extension_to_Joomla_2.5&amp;diff=36873</id>
		<title>Archived:Adapting a Joomla 1.5 extension to Joomla 2.5</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:Adapting_a_Joomla_1.5_extension_to_Joomla_2.5&amp;diff=36873"/>
		<updated>2011-02-08T16:31:54Z</updated>

		<summary type="html">&lt;p&gt;Drewgg: /* Plugin files now in different locations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{incomplete}}&lt;br /&gt;
&lt;br /&gt;
This article is written to help developers upgrade their extensions from Joomla 1.5 to Joomla 1.6. If you have any further tips, feel free to add them onto this wiki article.&lt;br /&gt;
&lt;br /&gt;
== System setup ==&lt;br /&gt;
This document assumes that you are running the program eclipse for your development. This will allow you to automate most of the Joomla conversion process. For more instructions on how to setup eclipse, see [[Setting up your workstation for Joomla! development]].&lt;br /&gt;
&lt;br /&gt;
== Background reading ==&lt;br /&gt;
[[What&#039;s new in Joomla 1.6#Developers]] describes most changes of Joomla 1.6 and how this affect developers.&lt;br /&gt;
&lt;br /&gt;
== Updating your Joomla 1.5 language files to work on Joomla 1.6 ==  &lt;br /&gt;
Using the native php ini parser for language files has many benefits including much faster performace. Converting your exisiting Joomla 1.5 into the new format is very easy if you use a coding platform like eclipse. Search your file for *.ini in your project of choice. Then use the following search/replace values to automatically, replace exisiting quotes, add quotes to string values and update your comments.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Double quotes are NOT allowed inside the string value&#039;&#039;&#039;, except when using &amp;quot;_QQ_&amp;quot; to represent them. In case of js use, better use html entities or single quotes.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
#Single quotes are allowed. &lt;br /&gt;
#Put a closing double quote at end of line if not empty or a comment.  Find ^((?!#).+)\R  replace with $1&amp;quot;\R&lt;br /&gt;
#Put an opening double quote at start of translated string if not empty or comment. Find ^((?!#).+?\=)(.+)\R replace with $1&amp;quot;$2\R&lt;br /&gt;
#Now replace the hash comments with the new semi colon. Find ^# and replace with ;&lt;br /&gt;
#Remove any illegal strings that can prevent files loading. Find ^(null|yes|no|true|false|on|off|none)=(.+)\R and replace with nothing.&lt;br /&gt;
&lt;br /&gt;
Enabling Debug System in Global configuration will display the parsing errors per file and lines.&lt;br /&gt;
&lt;br /&gt;
If you do not remove the illegal strings, then your language file will load until one of them is reached. The now &amp;quot;illegal&amp;quot; strings in the language file like NO, are handled by adding a &#039;J&#039; in-front of them.  Just make sure you change these language strings in your XML files as well. You can include in your language file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
;forbidden words&lt;br /&gt;
JNULL=&amp;quot;Null&amp;quot;&lt;br /&gt;
JYES=&amp;quot;Yes&amp;quot;&lt;br /&gt;
JNO=&amp;quot;No&amp;quot;&lt;br /&gt;
JTRUE=&amp;quot;True&amp;quot;&lt;br /&gt;
JFALSE=&amp;quot;False&amp;quot;&lt;br /&gt;
JON=&amp;quot;On&amp;quot;&lt;br /&gt;
JOFF=&amp;quot;Off&amp;quot;&lt;br /&gt;
JNONE=&amp;quot;None&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Changing Javascript function overrides ==&lt;br /&gt;
Joomla now has some of its Javascript functions prefixed with &amp;quot;Joomla&amp;quot;. This means the functions are always unique and won&#039;t clash with other javascript functions on your server/webpage. However, you now need a different method to override the default Joomla Javascript. The Joomla 1.5 method was:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
function submitbutton(pressbutton) {&lt;br /&gt;
var form = document.adminForm;&lt;br /&gt;
    if (pressbutton == &#039;applyconfig&#039;) {&lt;br /&gt;
        //do something unique&lt;br /&gt;
        form.action.value = &#039;apply&#039;&lt;br /&gt;
        submitform(&#039;saveconfig&#039;);&lt;br /&gt;
        return;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    submitform(pressbutton);&lt;br /&gt;
    return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
For Joomla 1.6 you need to copy your exisiting function but modify your top line to:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
Joomla.submitbutton = function(pressbutton) {&lt;br /&gt;
var form = document.adminForm;&lt;br /&gt;
    if (pressbutton == &#039;applyconfig&#039;) {&lt;br /&gt;
        //do something unique&lt;br /&gt;
        form.action.value = &#039;apply&#039;&lt;br /&gt;
        submitform(&#039;saveconfig&#039;);&lt;br /&gt;
        return;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    submitform(pressbutton);&lt;br /&gt;
    return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Changing removed functions ==&lt;br /&gt;
Some functions were removed for various reasons. You can find a list of them on [[What&#039;s new in Joomla_1.6#Removed_features]].&lt;br /&gt;
&lt;br /&gt;
Note that the ADODB compatibility methods included function like $db-&amp;gt;Execute($query) which now need a separate $db-&amp;gt;setQuery($query);$db-&amp;gt;Query();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Renamed events ==&lt;br /&gt;
&lt;br /&gt;
A large number of the Joomla 1.5 events have been renamed. Here is the list of renamed events.&lt;br /&gt;
*onContentAfterSave&lt;br /&gt;
*onContentAfterTitle&lt;br /&gt;
*onContentAfterDisplay&lt;br /&gt;
*onContentBeforeDisplay&lt;br /&gt;
*onContentBeforeSave&lt;br /&gt;
*onContentSearch&lt;br /&gt;
*onContentSearchAreas&lt;br /&gt;
*onUserAuthenticate&lt;br /&gt;
*onUserAfterDelete&lt;br /&gt;
*onUserAfterSave&lt;br /&gt;
*onUserBeforeDelete&lt;br /&gt;
*onUserBeforeSave&lt;br /&gt;
*onUserLogin&lt;br /&gt;
*onUserLogout&lt;br /&gt;
*All content events (except for search and search areas) now pass a &#039;context&#039; as the first argument to alert the plugin as to what type of content is being passed.  The plugin event may or may not heed this context.&lt;br /&gt;
&lt;br /&gt;
This means that if you use Joomla events you have two options:&amp;lt;br/&amp;gt;&lt;br /&gt;
1) rename the event and your extension can only be used on Joomla 1.6&amp;lt;br/&amp;gt;&lt;br /&gt;
2) create your own &amp;quot;legacy layer&amp;quot; and add the new event function name to your plugin. Here is an example of the user plugin:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
    //joomla 1.6 compatibility code &lt;br /&gt;
 	public function onUserLogin($user, $options){&lt;br /&gt;
 	    $result = $this-&amp;gt;onLoginUser($user, $options);&lt;br /&gt;
 	    return $result;&lt;br /&gt;
 	}&lt;br /&gt;
	public function onUserLogout($user)	{&lt;br /&gt;
 	    $result = $this-&amp;gt;onLogoutUser($user);&lt;br /&gt;
 	    return $result;&lt;br /&gt;
	}&lt;br /&gt;
	public function onUserAfterDelete($user, $succes, $msg)	{&lt;br /&gt;
 	    $result = $this-&amp;gt;onAfterDeleteUser($user, $succes, $msg);&lt;br /&gt;
 	    return $result;&lt;br /&gt;
	}&lt;br /&gt;
	public function onUserBeforeSave($user, $isnew, $new){&lt;br /&gt;
 	    $result = $this-&amp;gt;onBeforeStoreUser($user, $isnew, $new);&lt;br /&gt;
 	    return $result;	&lt;br /&gt;
	}&lt;br /&gt;
	public function onUserAfterSave($user, $isnew, $success, $msg){&lt;br /&gt;
 	    $result = $this-&amp;gt;onAfterStoreUser($user, $isnew, $success, $msg);&lt;br /&gt;
 	    return $result;			&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Changing name=&amp;quot;adminForm&amp;quot; to id=&amp;quot;adminForm&amp;quot; ==&lt;br /&gt;
To create your own admin forms in joomla you now need to use id=&amp;quot;adminForm&amp;quot;. This is because the use of the tag &amp;quot;name&amp;quot; is not valid HTML strict and has compatibility issues when used in XHTML served as XML.\. Although there is build in compatibility check to look for the old name=&amp;quot;adminForm&amp;quot; tag, it is best to add the new id tag. Depending on the features you want to use you may need to include both, name=&amp;quot;adminForm&amp;quot; and id=&amp;quot;adminForm&amp;quot; because not all core functionality has been updated to use id&#039;s.  An example of the new form code is:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&amp;lt;form method=&amp;quot;post&amp;quot; action=&amp;quot;index.php&amp;quot; name=&amp;quot;adminForm&amp;quot; id=&amp;quot;adminForm&amp;quot;&amp;gt;&amp;lt;/form&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Removing references to index2.php and index3.php ==&lt;br /&gt;
Joomla 1.0 had different index files to serve admin content in different manners. Joomla 1.6 has now got better way to handle this and you need to search your codebase for &amp;quot;index2.php&amp;quot; and &amp;quot;index3.php&amp;quot; to ensure you don&#039;t have any Joomla 1.0 style links. If you need to display your component without any of the other Joomla 1.6 admin content (menus, etc) then add the following to the url: &amp;quot;&amp;amp;tmpl=component&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Upgrading core table and field name usage ==&lt;br /&gt;
Many of the core Joomla tables have been simplified, combined or renamed. This was needed to get rid of some limitation dating back to Joomla 1.0. This means however that if you have code that directly manipulates Joomla tables, that you need to add a function that detects Joomla 1.6 and had different SQL queries based on the joomla version. Plase note that both tables and field names have been renamed or removed. An example is the following function that can find if a plugin is published on both Joomla 1.5 and 1.6:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;		&lt;br /&gt;
function getPluginStatus($element, $folder) {&lt;br /&gt;
    //get joomla specs&lt;br /&gt;
    $db = &amp;amp; JFactory::getDBO();		&lt;br /&gt;
    $version = new JVersion;&lt;br /&gt;
    $joomla = $version-&amp;gt;getShortVersion();&lt;br /&gt;
    if(substr($joomla,0,3) == &#039;1.6&#039;){&lt;br /&gt;
        //Joomla 1.6 code&lt;br /&gt;
        $query = &#039;SELECT published FROM #__extensions WHERE element=&#039; . $db-&amp;gt;Quote($element) . &#039; AND folder=&#039; . $db-&amp;gt;Quote($folder);&lt;br /&gt;
    } else {&lt;br /&gt;
        //Joomla 1.0/1.5 code&lt;br /&gt;
        $query = &#039;SELECT published FROM #__plugins WHERE element=&#039; . $db-&amp;gt;Quote($element) . &#039; AND folder=&#039; .   $db-&amp;gt;Quote($folder); &lt;br /&gt;
    }&lt;br /&gt;
    $db-&amp;gt;setQuery($query);&lt;br /&gt;
    $result = $db-&amp;gt;loadResult();&lt;br /&gt;
    return $result;&lt;br /&gt;
}	&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Changing in the XML installer manifest file ==&lt;br /&gt;
Joomla 1.6 now uses a more streamlined approach to the XML file inside the ZIP file that installs Joomla extentions.&lt;br /&gt;
&lt;br /&gt;
== New mootools version ==&lt;br /&gt;
Most important is that the Ajax class has been depreciated and replaced by the Request class. That means that if you use ajax calls you need to have a version switcher (below a sample code)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$version = new JVersion;&lt;br /&gt;
$joomla = $version-&amp;gt;getShortVersion();&lt;br /&gt;
&lt;br /&gt;
..... (your code) ....&lt;br /&gt;
&lt;br /&gt;
    /* our ajax istance for starting the sync */&lt;br /&gt;
    &amp;lt;?php  if(substr($joomla,0,3) == &#039;1.6&#039;){&lt;br /&gt;
 echo &#039;var ajax = new Request.HTML({&lt;br /&gt;
           url: url,&#039;;&lt;br /&gt;
    } else {&lt;br /&gt;
 echo &#039;var ajax = new Ajax(url, {&#039;;&lt;br /&gt;
    }?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
.... your code .....&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?php  if(substr($joomla,0,3) == &#039;1.6&#039;){&lt;br /&gt;
     echo &#039;var ajaxsync = new Request.HTML({&lt;br /&gt;
        url: url, &#039;;&lt;br /&gt;
    } else {&lt;br /&gt;
echo &#039;var ajaxsync = new Ajax(url, {&#039;;&lt;br /&gt;
    }?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
.... your code .....&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also another common usuage of mootools in  Joomla is the popup box. The Joomla 1.5 javascript code to close this box is:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;document.getElementById(&#039;sbox-window&#039;).close();&amp;lt;/source&amp;gt;&lt;br /&gt;
in Joomla 1.6 you need to use:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;window.parent.SqueezeBox.close();&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Converting your JParameters to JForms ==&lt;br /&gt;
Joomla 1.6 now uses the JForms class to handle parameters and it has also changed the way parameters are defined in your XML files. To make menu/component/module/plugin parameters work, first you need to update the XML file. Here is an automated way to handle the bulk of the conversion. (added &amp;quot;&amp;quot; to the examples below so you can see spaces in the search query as well). Use eclipse to search and replace parameters in *.xml files&lt;br /&gt;
&lt;br /&gt;
replace &amp;quot;&amp;lt;param &amp;quot; with &amp;quot;&amp;lt;field &amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
replace &amp;quot;&amp;lt;/param&amp;gt;&amp;quot; with &amp;lt;/field&amp;gt;&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
replace &amp;quot;&amp;lt;params&amp;gt; with &amp;quot;&amp;lt;config&amp;gt;&amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&amp;lt;fieldset name=&amp;quot;basic&amp;quot;&amp;gt;&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
replace &amp;quot;&amp;lt;params*?&amp;gt; with &amp;quot;&amp;lt;config&amp;gt;&amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&amp;lt;fieldset name=&amp;quot;basic&amp;quot;&amp;gt;&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
replace &amp;quot;&amp;lt;/params&amp;gt;&amp;quot; with &amp;quot;&amp;lt;/fieldset&amp;gt;&amp;lt;/fields&amp;gt;&amp;lt;/config&amp;gt;&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
replace &amp;quot;&amp;lt;install &amp;quot; with &amp;quot;&amp;lt;extension &amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
replace &amp;quot;&amp;lt;/install&amp;gt;&amp;quot; with &amp;quot;&amp;lt;/extension&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Change the &amp;quot;extension&amp;quot; node to add the following attributes:&lt;br /&gt;
* Keep the existing &amp;quot;type&amp;quot; attribute&lt;br /&gt;
* version=&amp;quot;1.6.0&amp;quot;&lt;br /&gt;
* client=&amp;quot;site&amp;quot;&lt;br /&gt;
* method=&amp;quot;upgrade&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Example for a module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;1.6.0&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now if you want to use your joomla extension on both Joomla 1.5 and 1.6 you will need to go to your &amp;quot;team synchronising&amp;quot; view in eclipse. Double click on your changed xml file, which will open the compare editor. Then simply copy-paste back your old Joomla 1.5 params into your new Joomla 1.6 xml file and save.&lt;br /&gt;
&lt;br /&gt;
If you have custom parameter types, you will need to do some additional work. In Joomla 1.5 you would use the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;params addpath=&amp;quot;/administrator/components/com_yourname/elements&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
In joomla 1.6 JParameter classes won&#039;t work and you will need to convert your jparameter fields into JForm fields. Create a new directory and copy your &amp;quot;old elements&amp;quot; into them. Then you need to load these new fields with the individual parameter&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;sample&amp;quot; type=&amp;quot;sampleField&amp;quot; size=&amp;quot;5&amp;quot; default=&amp;quot;&amp;quot;			label=&amp;quot;sampleField&amp;quot; description=&amp;quot;sampleField&amp;quot; addfieldpath=&amp;quot;/administrator/components/com_yourname/fields&amp;quot;/&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use eclipse to search and replace files in your newly created fields directory.&lt;br /&gt;
replace &amp;quot;JElement&amp;quot; with &amp;quot;JFormField&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
replace &amp;quot;var $_name =&amp;quot; with &amp;quot;public $type =&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
replace &amp;quot;function fetchElement($name, $value, &amp;amp;$node, $control_name)&amp;quot; with &amp;quot;protected function getInput()&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you still need to replace the references to $control_name and others in your new JForm field, but at least the bulk of the work has been done automatically&lt;br /&gt;
&lt;br /&gt;
== renamed core component names and login form parameters ==&lt;br /&gt;
A login module for Joomla 1.5 will not work without modifications on Joomla 1.6. Here is a part of the logout module that will work on both Joomla 1.5 and Joomla 1.6. You can compare the two to see the difference in input names.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
        $version = new JVersion;&lt;br /&gt;
        $joomla = $version-&amp;gt;getShortVersion();&lt;br /&gt;
        if(substr($joomla,0,3) == &#039;1.6&#039;){&lt;br /&gt;
            //joomla 1.6 format          &lt;br /&gt;
            $output .= &#039;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;task&amp;quot; value=&amp;quot;user.logout&amp;quot; /&amp;gt;&#039;;&lt;br /&gt;
            $output .= &#039;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;option&amp;quot; value=&amp;quot;com_users&amp;quot; /&amp;gt;&#039;;&lt;br /&gt;
        } else {    &lt;br /&gt;
            //joomla 1.5 format&lt;br /&gt;
            $output .= &#039;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;task&amp;quot; value=&amp;quot;logout&amp;quot; /&amp;gt;&#039;;&lt;br /&gt;
            $output .= &#039;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;option&amp;quot; value=&amp;quot;com_user&amp;quot; /&amp;gt;&#039;;            &lt;br /&gt;
        } &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
here is the code for the login module&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
        $version = new JVersion;&lt;br /&gt;
        $joomla = $version-&amp;gt;getShortVersion();&lt;br /&gt;
        if(substr($joomla,0,3) == &#039;1.6&#039;){        &lt;br /&gt;
            //joomla 1.6 format     &lt;br /&gt;
            $output .= &#039;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;task&amp;quot; value=&amp;quot;user.login&amp;quot; /&amp;gt;&#039;;&lt;br /&gt;
            $output .= &#039;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;option&amp;quot; value=&amp;quot;com_users&amp;quot; /&amp;gt;&#039;;&lt;br /&gt;
            $output .= &#039;&amp;lt;input id=&amp;quot;modlgn_passwd&amp;quot; type=&amp;quot;password&amp;quot; name=&amp;quot;password&amp;quot; class=&amp;quot;inputbox&amp;quot; size=&amp;quot;18&amp;quot; alt=&amp;quot;password&amp;quot; /&amp;gt; &#039;;&lt;br /&gt;
        } else {&lt;br /&gt;
            //joomla 1.5 format&lt;br /&gt;
            $output .= &#039;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;task&amp;quot; value=&amp;quot;login&amp;quot; /&amp;gt;&#039;;&lt;br /&gt;
            $output .= &#039;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;option&amp;quot; value=&amp;quot;com_user&amp;quot; /&amp;gt;&#039;;     &lt;br /&gt;
            $output .= &#039;&amp;lt;input id=&amp;quot;modlgn_passwd&amp;quot; type=&amp;quot;password&amp;quot; name=&amp;quot;passwd&amp;quot; class=&amp;quot;inputbox&amp;quot; size=&amp;quot;18&amp;quot; alt=&amp;quot;password&amp;quot; /&amp;gt; &#039;;               	&lt;br /&gt;
        }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These changes might also apply to front-end forms of other Joomla core components (more information needed)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ACL changes ==&lt;br /&gt;
Joomla 1.6 now has an advanced ACL system. It is unknown how this affects people that have previously used the ACL API in their extension. Please add some information here if you know more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Plugin files now in different locations ==&lt;br /&gt;
Joomla 1.6 now creates a different hierarchy structure for plugins.  Files are no longer placed where they used to be, so if your other parts of your application (comp, mods, etc.) expects them to be in a certain position, it won&#039;t work. The change has been that now plugins are in an additional subdirectory. If you only load your plugins via the 1.5 API you should be fine.&lt;br /&gt;
* Joomla 1.5 example location &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;JPATH_SITE . DS . &#039;plugins&#039; . DS . &#039;authentication&#039; . DS . &#039;example.php&#039;;&amp;lt;/source&amp;gt;&lt;br /&gt;
* Joomla 1.6 example location&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;JPATH_SITE . DS . &#039;plugins&#039; . DS . &#039;authentication&#039; . DS . &#039;example&#039;. DS . &#039;example.php&#039;;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Changes to view parameters ==&lt;br /&gt;
J!1.6 has a strict new way of specifying parameters for views.  J!1.5 allowed a bit of freedom where the parameters could be defined at the view.html.php level but now ithas to be at the tmpl level.  AE believes the view paramters were removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation process - preflight, postflight, etc ==&lt;br /&gt;
These are new events that can screw up an existing installlation process.  -1 on me for not documenting the process while stepping through xdebug.&lt;br /&gt;
They should be totally optional access points to the installation process.  But if your 1.5 install process is tricky for some reason, then these can be used to do clean up activities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Admin template changes ==&lt;br /&gt;
Admin functions that depended on certain functions, naming conventions etc no longer work.  Khepri has been removed.  Other admin functions/libraries may have changed.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ACL ==&lt;br /&gt;
gid and aid have been removed.  Significant changes to ACL archtecture.  Bricking refers to totally locking your self and everyone else out - Last chance backdoor involves adding a emergency pw to the config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==sys.ini language translation file==&lt;br /&gt;
This file has 3 purposes:&lt;br /&gt;
&lt;br /&gt;
1. It is used for installation process translations, when a folder language is included in the pack.&lt;br /&gt;
&lt;br /&gt;
pack/language/en-gb/en-gb.extension.ini&lt;br /&gt;
&lt;br /&gt;
pack/language/en-gb/en-gb.extension.sys.ini&lt;br /&gt;
&lt;br /&gt;
In this case, the &amp;lt;description&amp;gt;COM_MYCOMPONENT_XML_DESCRIPTION&amp;lt;/description&amp;gt; used in the sys.ini will display on installing/updating the extension.&lt;br /&gt;
&lt;br /&gt;
When editing the extension in administration, it will be the .ini version of COM_MYCOMPONENT_XML_DESCRIPTION which will display.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. It is used to replace the former .menu.ini&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. It is used to display the translated extension name in many managers.&lt;br /&gt;
&lt;br /&gt;
== removed include folders ==&lt;br /&gt;
Most of the 3rd party libraries (Archive, domit, js, PEAR, etc) in the include folder have been removed in J!1.6. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Use paths defined in defines.php. ==&lt;br /&gt;
(Note they are different for the site and the administration)&lt;br /&gt;
&lt;br /&gt;
[[Category:Joomla! 1.6]]&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Module Development]]&lt;br /&gt;
[[Category:Component Development]]&lt;br /&gt;
[[Category:Plugin Development]]&lt;/div&gt;</summary>
		<author><name>Drewgg</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Accessing_the_database_using_JDatabase&amp;diff=14718</id>
		<title>Accessing the database using JDatabase</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Accessing_the_database_using_JDatabase&amp;diff=14718"/>
		<updated>2009-06-22T15:24:00Z</updated>

		<summary type="html">&lt;p&gt;Drewgg: /* Misc Result Set Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Joomla provides a sopisticated database abstraction layer to simplify the usage for 3PD. This guide should help you using this layer.&lt;br /&gt;
&lt;br /&gt;
==Why should I use the Joomla database class?==&lt;br /&gt;
Joomla has been built with the ability to use several different kinds of SQL-database-systems and to run in a variety of environments with different table-prefixes. In addition to these functions, the class automatically creates the database connection. Besides instantiating the object, at a minimum, you only need 2 lines of code to get a result from the database in a variety of formats. Using the Joomla database layer ensures a maximum of compatibility and flexibility for your extension.&lt;br /&gt;
&lt;br /&gt;
==Preparing the query==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Get a database object&lt;br /&gt;
$db =&amp;amp; JFactory::getDBO();&lt;br /&gt;
&lt;br /&gt;
$query = &amp;quot;SELECT * FROM #__example_table WHERE id = 999999;&amp;quot;;&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First we instantiate the database object, then we prepare the query. You can use the normal SQL-syntax, the only thing you have to change is the table-prefix. To make this as flexible as possible, Joomla uses a placeholder for the prefix, the &amp;amp;ldquo;#__&amp;amp;rdquo;. In the next step, the $db-&amp;gt;setQuery(), this string is replaced with the correct prefix.&lt;br /&gt;
&lt;br /&gt;
Now, if we don&#039;t want to get information from the database, but insert a row into it, we need one more function. Every string-value in the SQL-syntax should be quoted. For example, MySQL uses backticks &amp;amp;#096;&amp;amp;#096; for names and single quotes &amp;amp;lsquo;&amp;amp;lsquo; for values. Joomla has some functions to do this for us and to ensure code compatibility between different databases. We can pass the names to the function $db-&amp;gt;nameQuote($name) and the values to the function $db-&amp;gt;Quote($value). &lt;br /&gt;
&lt;br /&gt;
A fully quoted query example is:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$query = &amp;quot;&lt;br /&gt;
  SELECT * &lt;br /&gt;
    FROM &amp;quot;.$db-&amp;gt;nameQuote(&#039;#__example_table&#039;).&amp;quot;  &lt;br /&gt;
    WHERE &amp;quot;.$db-&amp;gt;nameQuote(&#039;id&#039;).&amp;quot; = &amp;quot;.$db-&amp;gt;quote(&#039;999999&#039;).&amp;quot;;&lt;br /&gt;
  &amp;quot;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whatever we want to do, we have to set the query with the $db-&amp;gt;setQuery() function. Although you could write the query directly as a parameter for $db-&amp;gt;setQuery(), it&#039;s commonly done by first saving it in a variable, normally $query, and then handing this variable over. This helps writing clean, readable code.&lt;br /&gt;
&lt;br /&gt;
==== setQuery($query) ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;setQuery($query)&#039;&#039; method sets up a database query for later execution either by the query() method or one of the Load result methods.  &amp;lt;pre&amp;gt;$db =&amp;amp; JFactory::getDBO();&lt;br /&gt;
$query = &amp;quot;/* some valid sql string */&amp;quot;;&lt;br /&gt;
$db-&amp;gt;setQuery($query);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
The parameter $query must be a valid sql string, it can either be added as a string parameter or as a variable; generally a variable is preferred as it leads to more legible code and can help in debugging.&lt;br /&gt;
&lt;br /&gt;
setQuery() also takes three other parameters: $offset, $limit - both used in list pagination; and $prefix - an alternative table prefix. All three of these variables have default values set and can usually be ignored. &lt;br /&gt;
&lt;br /&gt;
==Executing the Query==&lt;br /&gt;
To execute the query, Joomla provides several functions, which differ in their return value.&lt;br /&gt;
&lt;br /&gt;
=== Basic Query Execution ===&lt;br /&gt;
&lt;br /&gt;
==== query() ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;query()&#039;&#039; method is the the basic tool for executing sql queries on a database. In Joomla it is most often used for updating or administering the database simple because the various load methods detail on this page have the query step built in to them.&lt;br /&gt;
&lt;br /&gt;
The syntax is very straightforward:&amp;lt;pre&amp;gt;$db =&amp;amp; JFactory::getDBO();&lt;br /&gt;
$query = &amp;quot;/* some valid sql string */&amp;quot;;&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$result = $db-&amp;gt;query();&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: $query() returns an appropriate database resource if successful, or FALSE if not&lt;br /&gt;
&lt;br /&gt;
=== Query Execution Information ===&lt;br /&gt;
* getAffectedRows()&lt;br /&gt;
* explain()&lt;br /&gt;
* insertid()&lt;br /&gt;
&lt;br /&gt;
=== Insert Query Execution ===&lt;br /&gt;
* insertObject()&lt;br /&gt;
&lt;br /&gt;
==Query Results ==&lt;br /&gt;
The database class contains many methods for working with a query&#039;s result set.&lt;br /&gt;
&lt;br /&gt;
=== Single Value Result ===&lt;br /&gt;
&lt;br /&gt;
==== loadResult() ====&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;loadResult()&#039;&#039;&#039; when you expect just a single value back from your database query. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! id !! name !! email !! username&lt;br /&gt;
|- &lt;br /&gt;
| 1 || style=&amp;quot;background:yellow&amp;quot; | John Smith || johnsmith@example.com || johnsmith&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Magda Hellman || magda_h@example.com || magdah&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Yvonne de Gaulle || ydg@example.com || ydegaulle&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is often the result of a &#039;count&#039; query to get a number of records:&lt;br /&gt;
&amp;lt;source lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
$db =&amp;amp; JFactory::getDBO();&lt;br /&gt;
$query = &amp;quot;&lt;br /&gt;
  SELECT COUNT(*)&lt;br /&gt;
    FROM &amp;quot;.$db-&amp;gt;nameQuote(&#039;#__my_table&#039;).&amp;quot;&lt;br /&gt;
    WHERE &amp;quot;.$db-&amp;gt;nameQuote(&#039;name&#039;).&amp;quot; = &amp;quot;.$db-&amp;gt;quote($value).&amp;quot;;&lt;br /&gt;
  &amp;quot;;&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$count = $db-&amp;gt;loadResult();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
or where you are just looking for a single field from a single row of the table (or possibly a single field from the first row returned).&lt;br /&gt;
&amp;lt;source lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
$db =&amp;amp; JFactory::getDBO();&lt;br /&gt;
$query = &amp;quot;&lt;br /&gt;
  SELECT &amp;quot;.$db-&amp;gt;nameQuote(&#039;field_name&#039;).&amp;quot;&lt;br /&gt;
    FROM &amp;quot;.$db-&amp;gt;nameQuote(&#039;#__my_table&#039;).&amp;quot;&lt;br /&gt;
    WHERE &amp;quot;.$db-&amp;gt;nameQuote(&#039;some_name&#039;).&amp;quot; = &amp;quot;.$db-&amp;gt;quote($some_value).&amp;quot;;&lt;br /&gt;
  &amp;quot;;&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$result = $db-&amp;gt;loadResult();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Single Row Results ===&lt;br /&gt;
&lt;br /&gt;
Each of these results functions will return a single record from the database even though there may be several records that meet the criteria that you have set. To get more records you need to call the function again.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! id !! name !! email !! username&lt;br /&gt;
|- style=&amp;quot;background:yellow&amp;quot;&lt;br /&gt;
| 1 || John Smith || johnsmith@example.com || johnsmith&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Magda Hellman || magda_h@example.com || magdah&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Yvonne de Gaulle || ydg@example.com || ydegaulle&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== loadRow() ====&lt;br /&gt;
&lt;br /&gt;
loadRow() returns an indexed array from a single record in the table: &lt;br /&gt;
&amp;lt;source lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$row = $db-&amp;gt;loadRow();&lt;br /&gt;
print_r($row);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will give:&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( [0] =&amp;gt; 1 [1] =&amp;gt; John Smith [2] =&amp;gt; johnsmith@example.com [3] =&amp;gt; johnsmith ) &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can access the individual values by using:&amp;lt;pre&amp;gt;$row[&#039;index&#039;] // e.g. $row[&#039;2&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
# The array indices are numeric starting from zero.&lt;br /&gt;
# Whilst you can repeat the call to get further rows, one of the functions that returns multiple rows might be more useful&lt;br /&gt;
&lt;br /&gt;
==== loadAssoc() ====&lt;br /&gt;
&lt;br /&gt;
loadAssoc() returns an associated array from a single record in the table: &lt;br /&gt;
&amp;lt;source lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$row = $db-&amp;gt;loadAssoc();&lt;br /&gt;
print_r($row);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will give:&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( [id] =&amp;gt; 1 [name] =&amp;gt; John Smith [email] =&amp;gt; johnsmith@example.com [username] =&amp;gt; johnsmith )&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can access the individual values by using:&amp;lt;pre&amp;gt;$row[&#039;name&#039;] // e.g. $row[&#039;name&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
# Whilst you can repeat the call to get further rows, one of the functions that returns multiple rows might be more useful&lt;br /&gt;
&lt;br /&gt;
==== loadObject() ====&lt;br /&gt;
&lt;br /&gt;
loadObject returns a PHP object from a single record in the table: &lt;br /&gt;
&amp;lt;source lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$result = $db-&amp;gt;loadObject();&lt;br /&gt;
print_r($result);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will give:&lt;br /&gt;
&amp;lt;pre&amp;gt;stdClass Object ( [id] =&amp;gt; 1 [name] =&amp;gt; John Smith [email] =&amp;gt; johnsmith@example.com [username] =&amp;gt; johnsmith )&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can access the individual values by using:&amp;lt;pre&amp;gt;$row-&amp;gt;index // e.g. $row-&amp;gt;email&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
# Whilst you can repeat the call to get further rows, one of the functions that returns multiple rows might be more useful&lt;br /&gt;
&lt;br /&gt;
===Single Column Results ===&lt;br /&gt;
&lt;br /&gt;
Each of these results functions will return a single column from the database. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! id !! name !! email !! username&lt;br /&gt;
|- &lt;br /&gt;
| 1 || style=&amp;quot;background:yellow&amp;quot; | John Smith || johnsmith@example.com || johnsmith&lt;br /&gt;
|-&lt;br /&gt;
| 2 || style=&amp;quot;background:yellow&amp;quot; | Magda Hellman || magda_h@example.com || magdah&lt;br /&gt;
|-&lt;br /&gt;
| 3 || style=&amp;quot;background:yellow&amp;quot; | Yvonne de Gaulle || ydg@example.com || ydegaulle&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== loadResultArray() ====&lt;br /&gt;
&lt;br /&gt;
loadResultArray() returns an indexed array from a single column in the table: &lt;br /&gt;
&amp;lt;source lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
$query = &amp;quot;&lt;br /&gt;
  SELECT name, email, username&lt;br /&gt;
    FROM . . . &amp;quot;;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$column= $db-&amp;gt;loadResultArray();&lt;br /&gt;
print_r($column);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will give:&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( [0] =&amp;gt; John Smith [1] =&amp;gt; Magda Hellman [2] =&amp;gt; Yvonne de Gaulle )&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can access the individual values by using:&amp;lt;pre&amp;gt;$column[&#039;index&#039;] // e.g. $column[&#039;2&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
# The array indices are numeric starting from zero.&lt;br /&gt;
# loadResultArray() is equivalent to loadResultArray(0)&lt;br /&gt;
&lt;br /&gt;
==== loadResultArray($index) ====&lt;br /&gt;
&lt;br /&gt;
loadResultArray($index) returns an indexed array from a single column in the table: &lt;br /&gt;
&amp;lt;source lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
$query = &amp;quot;&lt;br /&gt;
  SELECT name, email, username&lt;br /&gt;
    FROM . . . &amp;quot;;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$column= $db-&amp;gt;loadResultArray(1);&lt;br /&gt;
print_r($column);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will give:&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( [0] =&amp;gt; johnsmith@example.com [1] =&amp;gt; magda_h@example.com [2] =&amp;gt; ydg@example.com )&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can access the individual values by using:&amp;lt;pre&amp;gt;$column[&#039;index&#039;] // e.g. $column[&#039;2&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
loadResultArray($index) allows you to iterate through a series of columns in the results&lt;br /&gt;
&amp;lt;source lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
for ( $i = 0; $i &amp;lt;= 2; $i++ ) {&lt;br /&gt;
  $column= $db-&amp;gt;loadResultArray($i);&lt;br /&gt;
  print_r($column);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will give:&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( [0] =&amp;gt; John Smith [1] =&amp;gt; Magda Hellman [2] =&amp;gt; Yvonne de Gaulle )&lt;br /&gt;
Array ( [0] =&amp;gt; johnsmith@example.com [1] =&amp;gt; magda_h@example.com [2] =&amp;gt; ydg@example.com )&lt;br /&gt;
Array ( [0] =&amp;gt; johnsmith [1] =&amp;gt; magdah [2] =&amp;gt; ydegaulle )&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
# The array indices are numeric starting from zero.&lt;br /&gt;
&lt;br /&gt;
=== Multi-Row Results ===&lt;br /&gt;
&lt;br /&gt;
Each of these results functions will return multiple records from the database. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! id !! name !! email !! username&lt;br /&gt;
|- style=&amp;quot;background:yellow&amp;quot;&lt;br /&gt;
| 1 || John Smith || johnsmith@example.com || johnsmith&lt;br /&gt;
|- style=&amp;quot;background:yellow&amp;quot;&lt;br /&gt;
| 2 || Magda Hellman || magda_h@example.com || magdah&lt;br /&gt;
|- style=&amp;quot;background:yellow&amp;quot;&lt;br /&gt;
| 3 || Yvonne de Gaulle || ydg@example.com || ydegaulle&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== loadRowList() ====&lt;br /&gt;
&lt;br /&gt;
loadRowList() returns an indexed array of indexed arrays from the table records returned by the query: &lt;br /&gt;
&amp;lt;source lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$row = $db-&amp;gt;loadRowList();&lt;br /&gt;
print_r($row);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will give (with line breaks added for clarity):&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( &lt;br /&gt;
[0] =&amp;gt; Array ( [0] =&amp;gt; 1 [1] =&amp;gt; John Smith [2] =&amp;gt; johnsmith@example.com [3] =&amp;gt; johnsmith ) &lt;br /&gt;
[1] =&amp;gt; Array ( [0] =&amp;gt; 2 [1] =&amp;gt; Magda Hellman [2] =&amp;gt; magda_h@example.com [3] =&amp;gt; magdah ) &lt;br /&gt;
[2] =&amp;gt; Array ( [0] =&amp;gt; 3 [1] =&amp;gt; Yvonne de Gaulle [2] =&amp;gt; ydg@example.com [3] =&amp;gt; ydegaulle ) &lt;br /&gt;
)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can access the individual rows by using:&amp;lt;pre&amp;gt;$row[&#039;index&#039;] // e.g. $row[&#039;2&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
and you can access the individual values by using:&amp;lt;pre&amp;gt;$row[&#039;index&#039;][&#039;index&#039;] // e.g. $row[&#039;2&#039;][&#039;3&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
# The array indices are numeric starting from zero.&lt;br /&gt;
&lt;br /&gt;
==== loadAssocList() ====&lt;br /&gt;
&lt;br /&gt;
loadAssocList() returns an indexed array of associated arrays from the table records returned by the query: &lt;br /&gt;
&amp;lt;source lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$row = $db-&amp;gt;loadAssocList();&lt;br /&gt;
print_r($row);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will give (with line breaks added for clarity):&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( &lt;br /&gt;
[0] =&amp;gt; Array ( [id] =&amp;gt; 1 [name] =&amp;gt; John Smith [email] =&amp;gt; johnsmith@example.com [username] =&amp;gt; johnsmith ) &lt;br /&gt;
[1] =&amp;gt; Array ( [id] =&amp;gt; 2 [name] =&amp;gt; Magda Hellman [email] =&amp;gt; magda_h@example.com [username] =&amp;gt; magdah ) &lt;br /&gt;
[2] =&amp;gt; Array ( [id] =&amp;gt; 3 [name] =&amp;gt; Yvonne de Gaulle [email] =&amp;gt; ydg@example.com [username] =&amp;gt; ydegaulle ) &lt;br /&gt;
) &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can access the individual rows by using:&amp;lt;pre&amp;gt;$row[&#039;index&#039;] // e.g. $row[&#039;2&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
and you can access the individual values by using:&amp;lt;pre&amp;gt;$row[&#039;index&#039;][&#039;column_name&#039;] // e.g. $row[&#039;2&#039;][&#039;email&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== loadAssocList($key) ====&lt;br /&gt;
&lt;br /&gt;
loadAssocList(&#039;key&#039;) returns an associated array - indexed on &#039;key&#039; - of associated arrays from the table records returned by the query: &lt;br /&gt;
&amp;lt;source lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$row = $db-&amp;gt;loadAssocList(&#039;username&#039;);&lt;br /&gt;
print_r($row);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will give (with line breaks added for clarity):&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( &lt;br /&gt;
[johnsmith] =&amp;gt; Array ( [id] =&amp;gt; 1 [name] =&amp;gt; John Smith [email] =&amp;gt; johnsmith@example.com [username] =&amp;gt; johnsmith ) &lt;br /&gt;
[magdah] =&amp;gt; Array ( [id] =&amp;gt; 2 [name] =&amp;gt; Magda Hellman [email] =&amp;gt; magda_h@example.com [username] =&amp;gt; magdah ) &lt;br /&gt;
[ydegaulle] =&amp;gt; Array ( [id] =&amp;gt; 3 [name] =&amp;gt; Yvonne de Gaulle [email] =&amp;gt; ydg@example.com [username] =&amp;gt; ydegaulle ) &lt;br /&gt;
)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can access the individual rows by using:&amp;lt;pre&amp;gt;$row[&#039;key_value&#039;] // e.g. $row[&#039;johnsmith&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
and you can access the individual values by using:&amp;lt;pre&amp;gt;$row[&#039;key_value&#039;][&#039;column_name&#039;] // e.g. $row[&#039;johnsmith&#039;][&#039;email&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: Key must be a valid column name from the table; it does not have to be an Index or a Primary Key. But if it does not have a unique value you may not be able to retrieve results reliably.&lt;br /&gt;
&lt;br /&gt;
==== loadObjectList() ====&lt;br /&gt;
&lt;br /&gt;
loadObjectList() returns an indexed array of PHP objects from the table records returned by the query: &lt;br /&gt;
&amp;lt;source lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$result = $db-&amp;gt;loadObjectList();&lt;br /&gt;
print_r($result);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will give (with line breaks added for clarity):&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( &lt;br /&gt;
[0] =&amp;gt; stdClass Object ( [id] =&amp;gt; 1 [name] =&amp;gt; John Smith &lt;br /&gt;
    [email] =&amp;gt; johnsmith@example.com [username] =&amp;gt; johnsmith ) &lt;br /&gt;
[1] =&amp;gt; stdClass Object ( [id] =&amp;gt; 2 [name] =&amp;gt; Magda Hellman &lt;br /&gt;
    [email] =&amp;gt; magda_h@example.com [username] =&amp;gt; magdah ) &lt;br /&gt;
[2] =&amp;gt; stdClass Object ( [id] =&amp;gt; 3 [name] =&amp;gt; Yvonne de Gaulle &lt;br /&gt;
    [email] =&amp;gt; ydg@example.com [username] =&amp;gt; ydegaulle ) &lt;br /&gt;
)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can access the individual rows by using:&amp;lt;pre&amp;gt;$row[&#039;index&#039;] // e.g. $row[&#039;2&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
and you can access the individual values by using:&amp;lt;pre&amp;gt;$row[&#039;index&#039;]-&amp;gt;name // e.g. $row[&#039;2&#039;]-&amp;gt;email&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== loadObjectList(&#039;key&#039;) ====&lt;br /&gt;
&lt;br /&gt;
loadObjectList($key) returns an associated array - indexed on &#039;key&#039; - of objects from the table records returned by the query: &lt;br /&gt;
&amp;lt;source lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$row = $db-&amp;gt;loadObjectList(&#039;username&#039;);&lt;br /&gt;
print_r($row);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will give (with line breaks added for clarity):&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( &lt;br /&gt;
[johnsmith] =&amp;gt; stdClass Object ( [id] =&amp;gt; 1 [name] =&amp;gt; John Smith &lt;br /&gt;
    [email] =&amp;gt; johnsmith@example.com [username] =&amp;gt; johnsmith ) &lt;br /&gt;
[magdah] =&amp;gt; stdClass Object ( [id] =&amp;gt; 2 [name] =&amp;gt; Magda Hellman &lt;br /&gt;
    [email] =&amp;gt; magda_h@example.com [username] =&amp;gt; magdah ) &lt;br /&gt;
[ydegaulle] =&amp;gt; stdClass Object ( [id] =&amp;gt; 3 [name] =&amp;gt; Yvonne de Gaulle &lt;br /&gt;
    [email] =&amp;gt; ydg@example.com [username] =&amp;gt; ydegaulle ) &lt;br /&gt;
)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can access the individual rows by using:&amp;lt;pre&amp;gt;$row[&#039;key_value&#039;] // e.g. $row[&#039;johnsmith&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
and you can access the individual values by using:&amp;lt;pre&amp;gt;$row[&#039;key_value&#039;]-&amp;gt;column_name // e.g. $row[&#039;johnsmith&#039;]-&amp;gt;email&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: Key must be a valid column name from the table; it does not have to be an Index or a Primary Key. But if it does not have a unique value you may not be able to retrieve results reliably.&lt;br /&gt;
&lt;br /&gt;
=== Misc Result Set Methods ===&lt;br /&gt;
&lt;br /&gt;
==== getNumRows() ====&lt;br /&gt;
&lt;br /&gt;
getNumRows() will return the number of result rows found by the last query and waiting to be read. To get a result from getNumRows() you have to run it &#039;&#039;&#039;after&#039;&#039;&#039; the query and &#039;&#039;&#039;before&#039;&#039;&#039; you have retrieved any results.  &lt;br /&gt;
&amp;lt;source lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$db-&amp;gt;query();&lt;br /&gt;
$num_rows = $db-&amp;gt;getNumRows();&lt;br /&gt;
print_r($num_rows);&lt;br /&gt;
$result = $db-&amp;gt;loadRowList();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will return &amp;lt;pre&amp;gt;3&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note: if you run getNumRows() after loadRowList() - or any other retrieval method - you may get a PHP Warning:&lt;br /&gt;
&amp;lt;pre&amp;gt;Warning: mysql_num_rows(): 80 is not a valid MySQL result resource &lt;br /&gt;
in D:\xampp\htdocs\joomla1.5a\libraries\joomla\database\database\mysql.php on line 344&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Tips, Tricks &amp;amp; FAQ==&lt;br /&gt;
We had a few people lately using sub-queries like these:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;SQL&amp;quot;&amp;gt;&lt;br /&gt;
SELECT * FROM #__example WHERE id IN (SELECT * FROM #__example2);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
These kind of queries are only possible in MySQL 4.1 and above. Another way to achieve this, is splitting the query into two:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$query = &amp;quot;SELECT * FROM #__example2&amp;quot;;&lt;br /&gt;
$database-&amp;gt;setQuery($query);&lt;br /&gt;
$query = &amp;quot;SELECT * FROM #__example WHERE id IN (&amp;quot;. implode(&amp;quot;,&amp;quot;, $database-&amp;gt;loadArray()) .&amp;quot;)&amp;quot;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;noinclude&amp;gt;[[Category:Development]][[Category:Database]]&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Drewgg</name></author>
	</entry>
</feed>