YOOtheme Pro is here! The best WordPress and Joomla theme. Learn more

Extend global template parameters

This tutorial will walk you through the process of extending global template parameters in ZOO.

Getting started

All the global template parameters are located in /media/zoo/applications/APPLICATION/templates/TEMPLATE/template.xml.

In general you can include any Joomla parameter types, like text, radio, list, etc.

Getting into detail

A typical template.xml file might have the following params.

<params group="category">
	<param name="show_alpha_index" type="list" default="1" label="Alpha Index" description="Show/Hide alpha index">
		<option value="0">Hide</option>
		<option value="1">Show</option>
	</param>
	<param name="show_title" type="radio" default="1" label="Title" description="Show/Hide title">
		<option value="0">Hide</option>
		<option value="1">Show</option>
	</param>
	<param name="show_description" type="radio" default="1" label="Description" description="Show/Hide description">
		<option value="0">Hide</option>
		<option value="1">Show</option>
	</param>
	<param name="show_image" type="radio" default="1" label="Image" description="Show/Hide image">
		<option value="0">Hide</option>
		<option value="1">Show</option>
	</param>
	<param name="alignment" type="list" default="left" label="Alignment" description="You can choose how the image and the content should be aligned.">
		<option value="left">Image Left</option>
		<option value="right">Image Right</option>
		<option value="center">All Centered</option>
	</param>
	<param name="@spacer" type="spacer" />
	<param name="categories_cols" type="radio" default="4" label="Categories Columns" description="Set how many columns to use per row.">
		<option value="1">1</option>
		<option value="2">2</option>
		<option value="3">3</option>
		<option value="4">4</option>
	</param>
	<param name="show_categories_titles" type="radio" default="1" label="Categories Titles" description="Show/Hide categories titles">
		<option value="0">Hide</option>
		<option value="1">Show</option>
	</param>
	<param name="show_categories_item_count" type="radio" default="1" label="Categories Item Count" description="Show item count of categories">
		<option value="0">Hide</option>
		<option value="1">Show</option>
	</param>
	<param name="show_categories_descriptions" type="radio" default="1" label="Categories Descriptions" description="Show/Hide categories descriptions">
		<option value="0">Hide</option>
		<option value="1">Show</option>
	</param>
	<param name="show_categories_images" type="radio" default="1" label="Categories Images" description="Show/Hide categories images">
		<option value="0">Hide</option>
		<option value="1">Show</option>
	</param>
	<param name="show_sub_categories" type="radio" default="1" label="Sub Categories" description="Show/Hide sub categories">
		<option value="0">Hide</option>
		<option value="1">Show</option>
	</param>
	<param name="show_sub_categories_item_count" type="radio" default="1" label="Sub Categories Item Count" description="Show/Hide item count of sub categories">
		<option value="0">Hide</option>
		<option value="1">Show</option>
	</param>
	<param name="@spacer" type="spacer" />
	<param name="items_cols" type="radio" default="2" label="Item Columns" description="Set how many columns to use per row">
		<option value="1">1</option>
		<option value="2">2</option>
		<option value="3">3</option>
		<option value="4">4</option>
	</param>
	<param name="items_media_alignment" type="list" default="left" label="Items Media Alignment" description="You can choose how the media element should be aligned.">
		<option value="left">Left</option>
		<option value="right">Right</option>
		<option value="center">Center</option>
	</param>
</params>
<params group="item">
	<param name="item_media_alignment" type="list" default="right" label="Item Media Alignment" description="You can choose how the media element should be aligned.">
		<option value="left">Left</option>
		<option value="right">Right</option>
		<option value="center">Center</option>
		<option value="top">Top</option>
	</param>
</params>

You may add any parameters you like. They will automatically be converted to global template parameters. Depending on the params group, they will also show in the category and item template parameters.

To retrieve a parameter value in your templates, use $this->params->get('template.PARAM_NAME'). Notice the template. in front of the PARAM_NAME, it tells the parameter object where to look.

Documentation on Github

Help us out! If you are feeling that our documentation has errors or can be improved, fork it at Github and send us a pull request. Any contribution is much appreciated. Thank you!