Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 16582 программиста и 1769 роботов. Сейчас ищут 1638 программистов ...
HTML_Template_IT::setRoot()
Вернуться к: HTML_Template_IT
HTML_Template_IT::setRoot()
HTML_Template_IT::setRoot() – set the template root directory
Synopsis
require_once 'HTML/Template/IT.php';
void HTML_Template_IT::setRoot ( string $root )
Sets the path to the template directory where HTML_Template_IT::loadTemplatefile() searches for templates. Every filename is prefixed with the given string.
Parameter
-
string $root - Path to the template directory.
Example
Directorytree.
./
./testscript.php
./templates/design01/main.tpl.htm
./templates/design01/table.tpl.htm
./templates/design02/main.tpl.htm
./templates/design02/table.tpl.htm
script - testscript.php
<?php
/*
* testscipt.php - sets a random design
*/
require_once "HTML/Template/IT.php";
$tpl = new HTML_Template_IT();
$randomNumber = (int) round(rand(0,1));
switch ($randomNumber)
{
case 0:
// Set root to design01 so the called main.tpl.htm is searched there
$tpl->setRoot("./templates/design01");
break;
case 1:
default:
// Set root to design02 so the called main.tpl.htm is searched there
$tpl->setRoot("./templates/design02");
break;
}
/* Loads either ./templates/design01/main.tpl.htm
* or ./templates/design02/main.tpl.htm depending on the root directory set
* with setRoot in the switch */
$tpl->loadTemplatefile("main.tpl.htm", true, true);
/* ... assign variables .. */
// show
$tpl->show();
?>
Note
This function can not be called statically.
Вернуться к: HTML_Template_IT