HTML_Template_IT::loadTemplatefile()

HTML_Template_IT::loadTemplatefile() – Lädt ein Templatefile

Synopsis

require_once 'HTML/Template/IT.php';

boolean HTML_Template_IT::loadTemplatefile ( string $filename , boolean $removeUnknownVariables = = true , boolean $removeEmptyBlocks = = true )

Description

Lädt ein Templatefile und generiert intern Block- und Variablenlisten

Parameter

  • string $filename - Dateiname des zu ladenden Templates.

  • boolean $removeUnknownVariables - Wenn TRUE werden nicht zugewiesene Platzhalter in der Ausgabe entfernt, andernfalls bleiben diese sichtbar.

  • boolean $removeEmptyBlocks - Wenn TRUE, werden Blöcke, die keine Platzhalter enthalten und nicht durch HTML_Template_IT::touchBlock() gekennzeichnet sind, entfernt.

Return value

boolean - Returns TRUE on success, FALSE on failure.

Example

Templatefile main.tpl.htm

<html>
 <body>
User {USERNAME} logged in successfull as {ROLE}.
 </body>
</html>

Das Script mit $removeUnknownVariables = FALSE

<?php
require_once 'HTML/Template/IT.php';

$tpl = new HTML_Template_IT('.');
$tpl->loadTemplatefile ('main.tpl.htm'falsefalse);

$tpl->setVariable ('USERNAME''foo');
// Placeholder ROLE is not set
$tpl->show();
?>

Die Ausgabe


User foo logged in successfull as {ROLE}.

Das Script mit $removeUnknownVariables = TRUE

<?php
require_once 'HTML/Template/IT.php';

$tpl = new HTML_Template_IT('.');
$tpl->loadTemplatefile ('main.tpl.htm'truetrue);

$tpl->setVariable ('USERNAME''foo');
// Placeholder ROLE is not set, but $removeUnknownVariables is set to true.
$tpl->show();
?>

Die Ausgabe


User foo logged in successfull as .

Note

This function can not be called statically.