Actions

J1.5

Difference between revisions of "Using the core parameter types"

From Joomla! Documentation

(50% done)
(Fix red link)
 
(10 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{inuse}}
+
Parameters are one way that data may be stored for a Joomla! Extension. Each parameter consists of two parts:
 +
* A simple text string of the form {NAME} = {VALUE}, in which the parameter value is recorded. The strings are usually concatenated into a single string with other parameter values and stored in a table field.
 +
* A form field in the Extension backend that allows a user to enter the parameter value, and which is defined by an XML <code><param></code> element.
  
When you create an extension (component, module, plugin or template) you can implement parameters in the .XML file. With this parameters you can set options, and use them in the main file, the .PHP file. There are 20 extension parameter types available in Joomla! 1.5. You can use them easily and in this document you will find a description for all of them. You can also add your own parameters, you can find information about this specific part here: [[Creating_custom_XML_parameter_types]]
+
Joomla! defines 21 core parameter types, each of which gives a predefined behaviour and appearance in the back-end. This makes it very easy for developers to implement a range of form data entry types (text boxes, radio buttons, calendar selectors and so on) with a minimum of effort. This behaviour and appearance is determined by the <code>type</code> attribute of the <code><param></code> element. See [[J1.5:Standard parameter types]] for a complete list and details of each type.
 
+
<noinclude>[[Category:Development]][[Category:Parameters]]</noinclude>
== XML file ==
+
You need an XML file for every extension. It is used mainly to install the extension. A
+
particular XML file looks like this:
+
<source lang=xml>
+
<?xml version="1.0" encoding="utf-8"?>
+
<install version="1.5" type="extension type">
+
<name>Name of your extension</name>
+
<creationDate>Created Date</creationDate>
+
<author>Your name</author>
+
<authorEmail>Your e-mail address</authorEmail>
+
<authorUrl>Your website</authorUrl>
+
<copyright>Copyright</copyright>
+
<license>License, for example GNU/GPL</license>
+
<version>Version of the extension</version>
+
<description>Description of the extension</description>
+
<files>
+
<filename>add the files between those tags</filename>
+
</files>
+
<languages>
+
<language tag="en-GB">Language file</language>
+
</languages>
+
<params>
+
Place the parameters between these tags.
+
</params>
+
</install>
+
</source>
+
 
+
== Parameters ==
+
The parameters should be placed between the <code><params></code> and <code></params></code> tags. You can also
+
add groups. For example, the 'Advanced' group. This will look like this:
+
<source lang=xml>
+
<params>
+
'Normal' parameters
+
</params>
+
<params group="advanced">
+
Advanced parameters
+
</params></source>
+
Note: You can not add groups to templates.
+
 
+
=== Core Parameters ===
+
There are 20 parameter types available within your Joomla! 1.5 installation. These are:
+
Calendar, Category, Editors, File list, Folder list, Help sites, Hidden, Image list, Language, List,
+
Menu, Menu item, Password, Radio, Section, Spacer, SQL, Text, Text area and Time zones, and
+
will be described here in detail.
+
Each one is described in the following order:
+
*Description
+
*Screen shot of output
+
*XML file
+
*Implementation in PHP file
+
 
+
 
+
==== Calendar ====
+
'''Description:''' This parameter shows a text box where you can fill in the date. You can also choose
+
the date from a calendar, which pops up after you clicked on the icon next to the text
+
box.
+
 
+
'''Screen shot:'''
+
 
+
[[Image:Params.calendar.jpg]]
+
 
+
'''XML file:''' Use the following code in the XML file to create a parameter like this.
+
<source lang=xml><param name="calendar" type="Calendar" default="5-10-2008" label="Calendar"
+
description="" format="%d-%m-%Y" /></source>
+
*Name: The name used to implement in the PHP file.
+
*Type: For a calendar parameter, use 'Calendar'.
+
*Default: The default date.
+
*Label: The name displayed at the output of the parameter.
+
*Description: The description displayed as a tool tip.
+
*Format: The format of the date.
+
 
+
'''PHP file:''' For example, get the parameter, named publish_up, like this:
+
<source lang=php>
+
$publish_up = new JDate($row->publish_up);
+
</source>
+
*Reference: administrator\components\com_content\admin.content.html.php, 122-168
+
 
+
 
+
====Category====
+
'''Description:''' This parameter shows a drop down list of categories from a section.
+
 
+
'''Screen shot:'''
+
 
+
[[Image:Params.category.jpg]]
+
 
+
'''XML file:''' Use the following code in the XML file to create a parameter like this.
+
<source lang=xml><param name="category" type="Category" label="Category" description="" section="3" />
+
</source>
+
*Name: The name used to implement in the PHP file.
+
*Type: For a category parameter, use 'Category'.
+
*Label: The name displayed at the output of the parameter.
+
*Description: The description displayed as a tool tip.
+
*Section: The section ID number, can be found in the Section Manager.
+
'''PHP file:''' For example, get use the parameter, named category, like this:
+
<source lang=php>$category[$section->id][]
+
</source>
+
*Reference: administrator\components\com_content\controller.php, 452-530
+
 
+
 
+
====Editors====
+
'''Description:''' This parameter shows a drop down list of the available WYSIWYG editors.
+
'''Screen shot:'''
+
 
+
[[Image:Params.editors.jpg]]
+
 
+
'''XML file:''' Use the following code in the XML file to create a parameter like this.
+
<source lang=xml><param name="editors" type="Editors" default="" label="Editors" description="" /></source>
+
*Name: The name used to implement in the PHP file.
+
*Type: For an editor parameter, use 'Editor'.
+
*Default: The default editor.
+
*Label: The name displayed at the output of the parameter.
+
*Description: The description displayed as a tool tip.
+
'''PHP file:''' For example, get the parameter, named editors, like this:
+
<source lang=php>$this->lists['Editors']</source>
+
*Reference: administrator\components\com_config\controllers\application.php, 86
+
 
+
 
+
====File list====
+
'''Description:''' This parameter shows a drop down list of files from a certain directory.
+
'''Screen shot:'''
+
 
+
[[Image:Params.filelist.jpg]]
+
 
+
'''XML file:''' Use the following code in the XML file to create a parameter like this.
+
<source lang=xml><param name="filelist" type="Filelist" default="" label="File list"
+
description="" directory="" filter="" exclude="" stripext="" /></source>
+
*Name: The name used to implement in the PHP file.
+
*Type: For a file list parameter, use 'Filelist'.
+
*Default: The default file.
+
*Label: The name displayed at the output of the parameter.
+
*Description: The description displayed as a tool tip.
+
*Directory: The directory from which the files should be showed.
+
**For example “administrator”.
+
*Filter: Search in the files and only show the files containing this word or letter.
+
*Exclude: Exclude a certain file, file format or word from showing in the list.
+
*Stripext: Strip these characters.
+
'''PHP file:''' For example, get the parameter, named editors, like this:
+
<source lang=php>$params->get('ParameterName')</source>
+
 
+
====Folder list====
+
'''Description:''' This parameter shows a drop down list of folders from a certain directory.
+
'''Screen shot:'''
+
 
+
[[Image:Params.folderlist.jpg]]
+
 
+
'''XML file:''' Use the following code in the XML file to create a parameter like this.
+
<source lang=xml><param name="folderlist" type="Folderlist" default="" label="Folder list" description=""
+
directory="" filter="" exclude="" stripext="" /></source>
+
*Name: The name used to implement in the PHP file.
+
*Type: For a folder list parameter, use 'Folderlist'.
+
*Default: The default folder.
+
*Label: The name displayed at the output of the parameter.
+
*Description: The description displayed as a tool tip.
+
*Directory: The directory from which the folders should be showed.
+
**For example “administrator”.
+
*Filter: Search within the folders and only show the folders containing this word or letter.
+
*Exclude: Exclude a certain folder or some folders containing a certain word from showing in the list.
+
*Stripext: Strip these characters.
+
'''PHP file:''' For example, get the parameter, named headerColor, like this:
+
<source lang=php>$this->params->get('headerColor','green')</source>
+
*Reference: administrator\templates\khepri\cpanel.php, 45
+
 
+
 
+
====Help sites====
+
'''Description:''' This parameter shows a drop down list of the help sites of your Joomla! Installation. These can be found at administrator\help\helpsites-15.xml
+
'''Screen shot:'''
+
 
+
[[Image:Params.helpsites.jpg]]
+
 
+
 
+
'''XML file:''' Use the following code in the XML file to create a parameter like this.
+
<source lang=xml><param name="helpsites" type="Helpsites" default="local" label="Help sites" description="" /></source>
+
*Name: The name used to implement in the PHP file.
+
*Type: For a help site parameter, use 'Helpsites'.
+
*Default: The default editor.
+
*Label: The name displayed at the output of the parameter.
+
*Description: The description displayed as a tooltip.
+
'''PHP file:''' For example, get the parameter, named helpsites, like this:
+
<source lang=php>$this->params->get('helpsites','local')</source>
+
*Reference: administrator\components\com_config\controllers\application.php, 90-94
+
 
+
 
+
====Hidden====
+
'''Description:''' This parameter collects information about the user viewing the parameter section.
+
'''Screen shot:''' As the name says; this parameter is a hidden one. No output will be displayed.
+
'''XML file:''' Use the following code in the XML file to create a parameter like this.
+
<source lang=xml><param name="hidden" type="Hidden" value="" /></source>
+
*Name: The name used to implement in the PHP file.
+
*Type: For a hidden parameter, use 'Hidden'.
+
*Value: The data which needs to be collected.
+
**Two examples:
+
***Get ID of user: <source lang=xml>value="<?php echo $this->user->get('id'); ?>"</source>
+
***Get filter order: <source lang=xml>value="<?php echo $this->lists['order']; ?>"</source>
+
'''PHP file:''' For example, get the parameter, named id, like this:
+
<source lang=php>$user->get('id')</source>
+
*Reference: administrator\components\com_users\views\user\view.html.php, 52-76
+
 
+
 
+
====Image list====
+
'''Description:''' This parameter shows a drop down list with images; .png, .gif, .jpg, .bmp and .ico.
+
'''Screen shot:'''
+
 
+
[[Image:Params.imagelist.jpg]]
+
 
+
'''XML file:''' Use the following code in the XML file to create a parameter like this.
+
<source lang=xml>
+
<param name="imagelist" type="Imagelist" default="" label="Image list"
+
description="" directory="" exclude="" stripext="_" /></source>
+
*Name: The name used to implement in the PHP file.
+
*Type: For an image list parameter, use 'Imagelist'.
+
*Default: The default image.
+
*Label: The name displayed at the output of the parameter.
+
*Description: The description displayed as a tooltip.
+
*Directory: The directory from which the images should be showed.
+
**For example “images/stories”.
+
*Exclude: Exclude a certain image name, format or word from showing in the list.
+
*Stripext: Strip these characters.
+
'''PHP file:''' For example, get the parameter, named image, like this:
+
<source lang=php>JHTML::_('list.images', 'image', $row->image );</source>
+
*Reference: administrator\components\com_categories\admin.categories.php, 386
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
[[Image:Params.language.jpg]]
+
[[Image:Params.list.jpg]]
+
[[Image:Params.menu.jpg]]
+
[[Image:Params.menuitem.jpg]]
+
[[Image:Params.password.jpg]]
+
[[Image:Params.radio.jpg]]
+
[[Image:Params.section.jpg]]
+
[[Image:Params.spacer.jpg]]
+
[[Image:Params.sql.jpg]]
+
[[Image:Params.text.jpg]]
+
[[Image:Params.textarea.jpg]]
+
[[Image:Params.timezones.jpg]]
+

Latest revision as of 03:25, 11 June 2013

Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Parameters are one way that data may be stored for a Joomla! Extension. Each parameter consists of two parts:

  • A simple text string of the form {NAME} = {VALUE}, in which the parameter value is recorded. The strings are usually concatenated into a single string with other parameter values and stored in a table field.
  • A form field in the Extension backend that allows a user to enter the parameter value, and which is defined by an XML <param> element.

Joomla! defines 21 core parameter types, each of which gives a predefined behaviour and appearance in the back-end. This makes it very easy for developers to implement a range of form data entry types (text boxes, radio buttons, calendar selectors and so on) with a minimum of effort. This behaviour and appearance is determined by the type attribute of the <param> element. See J1.5:Standard parameter types for a complete list and details of each type.