Actions

J1.5

Retrieving parameter data in a template file

From Joomla! Documentation

Revision as of 09:37, 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.
Retrieving parameter data in a template file

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; ?>