HTML_Template_IT::loadTemplatefile()
Synopsis
boolean
HTML_Template_IT::loadTemplatefile
(
string
$filename
, boolean
$removeUnknownVariables
= true
, boolean
$removeEmptyBlocks
= true
)
Описание
Loads a template from a file and generates internal lists for blocks and variables.
Parameter
-
string $filename
- file to load -
boolean $removeUnknownVariables
- if TRUE, not substituted placeholders in a block will be removed -
boolean $removeEmptyBlocks
- if TRUE, not touched blocks will be removed. Blocks can be touched with HTML_Template_IT::touchBlock().
Return value
boolean
-
Returns TRUE on success, FALSE on failure.
Пример
Templatefile main.tpl.htm
<html> <body> User {USERNAME} logged in successfull as {ROLE}. </body> </html>
Script with $removeUnknownVariables
= FALSE
<?php
require_once 'HTML/Template/IT.php';
$tpl = new HTML_Template_IT('.');
$tpl->loadTemplatefile ('main.tpl.htm', false, false);
$tpl->setVariable ('USERNAME', 'foo');
// Placeholder ROLE is not set
$tpl->show();
?>
Output
User foo logged in successfull as {ROLE}.
Script with $removeUnknownVariables
= TRUE
<?php
require_once 'HTML/Template/IT.php';
$tpl = new HTML_Template_IT('.');
$tpl->loadTemplatefile ('main.tpl.htm', true, true);
$tpl->setVariable ('USERNAME', 'foo');
// Placeholder ROLE is not set, but $removeUnknownVariables is set to true.
$tpl->show();
?>
Output
User foo logged in successfull as .
Замечание
This function can not be called statically.