Zend Framework 中的自定义视图助手与操作视图助手
我想知道何时从视图中调用像这样的自定义视图助手
<?php
class Zend_View_Helper_MyHelper
{
public $view;
public function setView(Zend_View_Interface $view)
{
$this->view = $view;
}
public function myHelper()
{
return $this->view->escape(
’This is being output from the custom helper <br />’
);
}
}
?>
和操作视图助手。
谢谢。 叶希亚·萨拉姆
I was wondering when to call from the view a Custom View Helper like this one
<?php
class Zend_View_Helper_MyHelper
{
public $view;
public function setView(Zend_View_Interface $view)
{
$this->view = $view;
}
public function myHelper()
{
return $this->view->escape(
’This is being output from the custom helper <br />’
);
}
}
?>
and an action view helper.
Thanks.
Yehia A.Salam
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你为什么要这样做?
您可以轻松地执行:
然后执行:
myHelper(); ?>
在你的视图脚本上
Why would you do this?
You could easily do:
and then do a:
<?php echo $this->myHelper(); ?>
on your view script
在ZF中,有View Helper和Action Helper,这里已经讨论过很多次了,不再重复。但 Ben 问“什么是 Action View 助手?”
Action View Helper 是调用控制器的操作的 View Helper。
以下是 ZF 手册中 Action View Helper 的示例:
In ZF, there are View Helper and Action Helper, which have been discussed here so so many times so I won't repeat. But Ben asked "What is Action View helper?"
Action View Helper is a View Helper that calls an action of a controller.
Here is an example of Action View Helper from ZF manual: