How do I extend the Zend Navigation Menu View Helper?

For programming and general questions on Zend Framework

How do I extend the Zend Navigation Menu View Helper?

Postby sonnysavage on Tue Mar 02, 2010 5:52 pm

I need to change the output of Zend_View_Helper_Navigation_Menu. I want to change the class of the <li> elements and remove the EOL and indentation. There are no options to do that with the menu view script, which is why I'll have to extend it. I've found the two functions that I'll need to modify, and I know how to make the changes I need. What I don't know is how to make the Navigation object use my view helper instead of the Zend one.

Code snippet representing my class extension:

Code: Select all
// file /library/My/View/Helper/Navigation/Menu.php
class My_View_Helper_Navigation_Menu extends Zend_View_Helper_Navigation_Menu
{
    protected function _renderDeepestMenu(Zend_Navigation_Container $container,
                                          $ulClass,
                                          $indent,
                                          $minDepth,
                                          $maxDepth)
    {
        // modified code here
    }

    protected function _renderMenu(Zend_Navigation_Container $container,
                                   $ulClass,
                                   $indent,
                                   $minDepth,
                                   $maxDepth,
                                   $onlyActive)
    {
        // modified code here
    }
}
sonnysavage
 
Posts: 62
Joined: Thu Dec 10, 2009 3:12 pm

Re: How do I extend the Zend Navigation Menu View Helper?

Postby keyne on Tue Mar 02, 2010 7:06 pm

keyne
 
Posts: 53
Joined: Fri Jan 29, 2010 2:52 pm

Re: How do I extend the Zend Navigation Menu View Helper?

Postby sonnysavage on Wed Mar 03, 2010 1:03 am

I did see it, and I also had this posting there: http://stackoverflow.com/questions/2364 ... iew-helper

It's solved now, thanks!
sonnysavage
 
Posts: 62
Joined: Thu Dec 10, 2009 3:12 pm


Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 4 guests