J1.5

Retrieving parameter data in a template file

From Joomla! Documentation

Revision as of 18:27, 14 January 2008 by Chris Davenport (talk | contribs) (1 revision(s))
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The "J1.5" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Retrieving parameter data in a template file[edit]

To retrieve a Parameter in your template file use the function call

<?php 
$myParam = $this->params->get( 'parameterName' ); 
?>

For example, retrieve the two Parameters we set on the page Defining a parameter in templateDetails.xml

For the templateColor Parameter we have set the option values blue, red, green and black, this values refers to a CSS file. So we set a link to the color CSS file.

<?php
$tplColor = $this->params->get( 'templateColor' );
$this->addStyleSheet( $this->baseurl  .'/templates/'. $this->template .'/css/'. $tplColor .'.css' );
?>

For the authorCopyright Parameter we have set the option values 0 and 1 to hide or show a copyright notice for i.e. on the end of the template.

<?php if ($this->params->get( 'authorCopyright' )) : ?>   
     <div class="copyright">
         Your code...
     </div>
<?php endif; ?>