あなたが変数、$url
、およびアクセスとしてUrl
を通過することができなければならない }
ビュー/それは{$url->test()}
とあなたの視野の中でそれ。あなたがUrl::test()
のような静的関数にアクセスできるかどうかはわかりません。
あなたが同じビューでヘルパーを使用している場合は、ビューで変数をバインドする新しいコントローラを作成することができます
<?php
// application/classes/controller/site.php
class Controller_Site extends Controller_Template
{
public $template = 'smarty:my_template';
public function before()
{
$this->template->set_global('url_helper', new Url);
}
}
?>
を次に、あなたの他のコントローラでそれを拡張:
<?php
// application/classes/controller/welcome.php
class Controller_Welcome extends Controller_Site
{
public function action_index()
{
$this->template->content = 'Yada, yada, yada...';
}
}
そして、あなたの意見の中からアクセス:
{* application/views/my_template.tpl *}
<p>This is a {$url_helper->test()}.</p>
<p>{$content}</p>
をあなたは "PHPのタグ –