What is Smarty?
Why use it?
Use Cases and Work Flow
Syntax Comparison
Template Inheritance
Best Practices
Crash Course
You may use the Smarty logo according to the trademark notice.
For sponsorship, advertising, news or other inquiries, contact us at:
通常は、Smarty の設定変更は Smarty クラス変数
を使って行います。さらに、プラグインやフィルタなどを
Smarty 関数
で登録することもできます。Smarty オブジェクトで設定した内容は、
すべてのテンプレートに適用されます。
しかし、Smarty クラス変数や関数には、個々のテンプレートオブジェクトからアクセスすることもできます。 テンプレートオブジェクトで設定した内容は、そのテンプレート自身と そのテンプレートがインクルードしている子テンプレートに対してのみ適用されます。
Example 15.4. テンプレートでの Smarty の設定の変更
<?php $tpl = $smarty->createTemplate('index.tpl); $tpl->cache_lifetime = 600; // あるいは $tpl->setCacheLifetime(600); $smarty->display($tpl); ?>
Example 15.5. テンプレートでのプラグインの登録
<?php $tpl = $smarty->createTemplate('index.tpl); $tpl->registerPlugin('modifier','mymodifier'); $smarty->display($tpl); ?>