予約変数 {$smarty}
リクエスト変数の表示
$_GET変数を表示します。($_GET['hoge'])
テンプレート
{$smarty.get.hoge}
$_POST変数を表示します。($_POST['hoge'])
テンプレート
{$smarty.post.hoge}
クッキーの変数を表示します。($_COOKIE['hoge'])
テンプレート
{$smarty.cookies.hoge}
phpのセッション変数の値を表示します。($_SESSION['hoge'])
テンプレート
{$smarty.session.hoge}
サーバ変数を表示します。($_SERVER['SERVER_NAME'])
テンプレート
{$smarty.server.SERVER_NAME}
{$smarty.server.SCRIPT_NAME} は、{$SCRIPT_NAME} でもアクセス可能です。
環境変数の値を表示します。(環境変数"PATH")
テンプレート
{$smarty.env.PATH}
get/post/cookies/server/envの値を表示します。(変数"hoge")
テンプレート
{$smarty.request.hoge}
{$smarty.const}
PHP 定数の値を表示します。
PHP
define('HOGE','テスト');
テンプレート
{$smarty.const.HOGE}
configファイル変数"hoge"を表示します。
設定ファイル foo.conf:
hoge = "test"
テンプレート
{config_load file='foo.conf'} {$smarty.config.hoge}
{$smarty.capture}
テンプレート
{capture name=hoge} テスト {/capture} {$smarty.capture.hoge}
{$smarty.now}
現在の タイムスタンプ を表示します。
[UNIXタイム (1970年1月1日) からの経過秒数]
date_format 修飾子に渡し整形して表示させることもできます。
実行するたびに time() がコールされるので、同一のテンプレート内で同じ値が返されるとは限らない。
最初と最後でそれぞれ $smarty.nowがあるテンプレートの表示に10秒かかったとしたら、時間差が出る。
テンプレート
{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}
{$smarty.section}、{$smarty.foreach}
{section} および {foreach} のループプロパティを参照します。
この中には .first、.index などがあります。
{$smarty.template}
現在処理中のテンプレートの名前を返します。
テンプレート
{$smarty.template}
{$smarty.version}
テンプレートをコンパイルした Smarty のバージョンを返します。
テンプレート
{$smarty.version}
{$smarty.ldelim}、{$smarty.rdelim}
スポンサーリンク