I'm trying to create a custom navigation for zend navigation but i have two questions:
- How do i pass variables to custom partial phtml, or if it's possible?
- How do i set a class trough the whole active menu tree?
This is my code so far:
in the controller:
$config = new Zend_Config($menu);
$nav = new Zend_Navigation();
$nav->addPages($config);
$this->view->nav = $nav;
in the view:
<?php echo $this->navigation($this->nav)->menu()->setPartial('menu.phtml')->render(); ?>
and my partial:
<?php
function genMenu($container)
{
foreach ($container as $page)
{
echo '<li>';
$href = $page->uri;
$target = '_self';
echo '<a href="' . $href . '" target="' . $target . '">' . $page->label . '</a>';
if (!empty($page->pages))
{
echo '<ul>';
genMenu($page->pages);
echo '</ul>';
}
echo '</li>';
}
}
echo '<ul>';
genMenu($this->container);
echo '</ul>';
Thanks everyone in advance!