0

我想从 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,我该怎么做?

谢谢你。

4

1 回答 1

1

使用partial()代替render()

$this->_view->partial('partials/_action-navigation.phtml', array('nav' => $container));

在你的部分:

$this->nav // to get your container
于 2012-04-12T10:32:50.897 回答