J1.5:Defining a parameter in templateDetails.xml
m (1 revision(s)) |
m |
||
| Line 33: | Line 33: | ||
</source> | </source> | ||
| − | <noinclude>[[Category:Intermediate]] | + | <noinclude>[[Category:Intermediate]] |
| − | + | [[Category:Templates]] | |
| − | + | [[Category:Topics]] | |
| + | [[Category:Parameters]] | ||
| + | </noinclude> | ||
Revision as of 05:55, 29 April 2008
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).
<params> <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> <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> </param> </params>
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.
templateColor=blue authorCopyright=1
