0
votes

i want to send some data from Action Helper to view Partial and i am unable to do it, to get the clear picture. here is all the related code i am using.

in my layout.phtml i am using this placeholder. to generate onDemand navigation menu.

<?php echo $this->placeholder('action-navigation'); ?>

so when i need it in my controller or action method i can simply place use this code.

$this->_helper->navigation()->renderActionNavigation();

The Action helper i am using is.

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');
    }
}

this is my view partial _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();

i have problem sending data from action helper to partial view _action-navigation.phtml how do i do it?

Thank you.

1

1 Answers

1
votes

Use partial() instead of render():

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

And in your partial:

$this->nav // to get your container