HTML_Template_IT::loadTemplatefile() -- テンプレートファイルを読み込む
説明
ファイルからテンプレートを読み込み、
ブロックおよび変数の内部リストを作成します。
パラメータ
string $filename -
ロードするファイル
boolean $removeUnknownVariables -
TRUE であれば、置換されなかったブロック内のプレースホルダは除去されます。
boolean $removeEmptyBlocks -
TRUE であれば、タッチされなかったブロックは除去されます。
ブロックをタッチするには HTML_Template_IT::touchBlock()
を使用します。
返り値
boolean -
成功時には TRUE 、
失敗時には FALSE を返します。
例
例 47-1 テンプレートファイル main.tpl.htm
<html>
<body>
User {USERNAME} logged in successfull as {ROLE}.
</body>
</html> |
$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');
// プレースホルダ ROLE が設定されていません
$tpl->show();
?>
|
出力
User foo logged in successfull as {ROLE}. |
$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');
// プレースホルダ ROLE が設定されていませんが、
// $removeUnknownVariables が true に設定されています
$tpl->show();
?>
|
出力
User foo logged in successfull as . |
|
注意
この関数は、スタティックにコールする
ことはできません。
|
HTML_Template_IT::getGlobalvariables() (Previous)
|
(Next) HTML_Template_IT::parse()
|
|
|
Download Documentation
|
Last updated: Sun, 05 Oct 2008 |
|
Do you think that something on this page is wrong? Please file a bug report or add a note.
|
| User Notes: |
Note by: pierre2543@hotmail.com
It is possible to do file includes when calling loadTemplatefile.
File sample.tlp:
<html>
<body>
<!-- INCLUDE include.inc -->
</body>
</html>
File include.inc:
<h1>foo</h1>
Calling:
$it->loadTemplatefile('sample.tpl');
Result:
<html>
<body>
<h1>foo</h1>
</body>
</html>
------------------------
Louis-Pierre Charbonneau
|
|