Categories
Zend Framework 1.12

Generating Custom Menu’s with Zend_Navigation

Zend navigation has a number of advantages although performance isn’t one of them:
Access Control
and some others

But it is difficult to add custom code such as drop down carets and glyphicons etc.

It has been noted that the community of zend, and myself, do not like Zend Decorators and hence decorators are not planned for Zend_Navigation.

We can make Custom Zend_Navigation code with: Partials
Taken from StackOverflow, thanks!

how To:

#In Render.phtml:


$partial = array('menu.phtml', 'cms');
$this->navigation()->menu()->setPartial($partial);
echo $this->navigation()->menu()->render();

#In Menu.phtml:


container as $page)
{
$html[] = "

  • ";
    $html[] = $this->menu()->htmlify($page) . PHP_EOL;

    if (!empty($page->pages))
    {
    $html[] = "

    ";
    }

    $html[] = "

  • ";
    }

    echo join(PHP_EOL, $html);

    ?>