【发布时间】:2011-08-30 06:04:30
【问题描述】:
问题:我无法通过操作助手的 init 方法将我的变量传递给我的自定义布局。
我有这个动作助手“My_Action_Helper_Initializer”:
class My_Action_Helper_Initializer extends Zend_Controller_Action_Helper_Abstract
{
public function init()
{
$controller=$this->getActionController();
//variable passed to controller's view
$controller->view->flop="FLOOP!!";
//variable passed to controller
$controller->boom="BOOM!!";
}
}
在我的控制器“IndexController”中:
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
//print the variable passed from action helper
echo $this->boom;
}
}
然后在我的“layout.phtml”中:
//print variable passed from action helper
echo $this->flop;
所以控制器动作回显的“boom”变量显示正确。
-
“flop”变量(传递给我的布局)未显示。
问题:为什么传递给控制器动作的变量正确输出,而传递给布局视图的另一个变量却没有?
谢谢
卢卡
【问题讨论】:
-
回声 $this->boom;在布局脚本中?
-
我的错误是 $this->flop 谢谢
标签: php zend-framework layout controller helpers