Defining a parameter in templateDetails.xml

From Joomla! Documentation

Revision as of 09:29, 3 November 2007 by CirTap

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.
Defining a parameter in templateDetails.xml

Template Parameters gives you the possibility to pass variables to the template. The <params> element contains sub-elements for each Parameter that is set for the template. The site administrator can change the values of Parameters from the "Template: [ Edit ]" page in the Back-end.

For example, we set up two Parameters (Template color variation, show/hide Author Copyright).

    <param name="templateColor" type="list" default="blue" 
            label="Template Color" description="Choose the template color.">
        <option value="blue">Blue</option>
        <option value="red">Red</option>
        <option value="green">Green</option>
        <option value="black">Black</option>
    <param name="authorCopyright" type="radio" default="1" 
            label="Author Copyright" description="Show/Hide author copyright.">
        <option value="0">hide</option>
        <option value="1">show</option>

In the Template Manager -> Template: [ Edit ] page you now see a block "Parameters" with the two Parameters we defined above. To retrieve the Parameters in your template index.php see Retrieving parameter data in a template file

Note: In order that the Parameters works you need a file called params.ini in your template root folder. This file is used by Joomla! to store the settings for the Parameters. It can be a blank file, but it must be writeable so changes can be made.

For the example above the file looks like this.