我想从 Action Helper 发送一些数据来查看 Partial,但我无法做到这一点,以获得清晰的画面。这是我正在使用的所有相关代码。
在我的layout.phtml
我使用这个占位符。生成按需导航菜单。
<?php echo $this->placeholder('action-navigation'); ?>
所以当我在我的控制器或操作方法中需要它时,我可以简单地使用这个代码。
$this->_helper->navigation()->renderActionNavigation();
我正在使用的动作助手是。
class Zend_Controller_Action_Helper_Navigation extends Zend_Controller_Action_Helper_Abstract
{
private $_view = null;
public function direct()
{
$this->_view = $view = Zend_Layout::getMvcInstance()->getView();
$this->_view->placeholder('action-navigation');
return $this;
}
public function renderActionNavigation()
{
$config = new Zend_Config_Xml(
APPLICATION_PATH.'/configs/navigation.xml', strtolower(
$this->getRequest()->getControllerName().
$this->getRequest()->getActionName()
)
);
$container = new Zend_Navigation($config);
// here i want to send $container to _action-navigation.phtml.
$this->_view->addScriptPath(APPLICATION_PATH.'/layouts/')->render('partials/_action-navigation.phtml');
}
}
这是我的部分观点_action-navigation.phtml
$this->placeholder('action-navigation')->captureStart();
//i want to get zend_navigation instance. from the above action helper here.
$this->placeholder('action-navigation')->captureEnd();
我在将数据从动作助手发送到部分视图时遇到问题_action-navigation.phtml
,我该怎么做?
谢谢你。