Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 23486 программистов и 1607 роботов. Сейчас ищет 1091 программист ...

HTML_Template_IT::loadTemplatefile()

Вернуться к: HTML_Template_IT

HTML_Template_IT::loadTemplatefile()

HTML_Template_IT::loadTemplatefile() – load a template file

Synopsis

require_once 'HTML/Template/IT.php';

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.

Example

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'falsefalse);

$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'truetrue);

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

Output


User foo logged in successfull as .

Note

This function can not be called statically.



Вернуться к: HTML_Template_IT

© 2024 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware