Source code for file /joomla/template/template.php
Documentation is available at template.php
* @version $Id: template.php 6472 2007-02-03 10:47:26Z pasamio $
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
// Check to ensure this file is within the rest of the framework
jimport('pattemplate.patTemplate');
* Template class, provides an easy interface to parse and display a template file
* @package Joomla.Framework
* The path of the template file
* A hack to support __construct() on PHP 4
* Hint: descendant classes have no PHP4 class_name() constructors,
* so this constructor gets called first and calls the top-layer __construct()
* which (if present) should call parent::__construct()
* The type influences the tags you are using in your templates.
//set root template directory
* Returns a reference to a global Template object, only creating it
* if it doesn't already exist.
* @param string $type (either html or tex)
* @return jtemplate A template object
if (!isset
( $instances )) {
if (empty($instances[$signature])) {
$instances[$signature] =
new JTemplate($type);
return $instances[$signature];
* @param string $file The filename
$this->_file =
$file; //store the file for later usage
* Execute and display a the template
* @param string $name The name of the template
* Returns a parsed template
* @param string $name The name of the template
* enable a template cache
* A template cache will improve performace, as the templates
* do not have to be read on each request.
* @param string name of the template cache
* @param string folder to store the cached files
* @return boolean true on success, patError otherwise
'cacheFolder' =>
$folder,
* Set the prefix of the template cache
* @param string the prefix of the template cache
* @return boolean true on success, patError otherwise
if (!$this->_tmplCache) {
$this->_tmplCache->_params['prefix'] =
$prefix;
* load from template cache
* @param string name of the input (filename, shm segment, etc.)
* @param string driver that is used as reader, you may also pass a Reader object
* @param array options for the reader
* @param string cache key
* @return array|boolean either an array containing the templates, or false
function _loadTemplatesFromCache( $input, &$reader, $options, $key )
$stat->setOptions( $options );
$modTime =
$stat->getModificationTime( $this->_file );
$templates =
$this->_tmplCache->load( $key, $modTime );