Question

I'm using Zend/Navigation in Zend Framework 2. It prints this:

<ul class="Navigation">
    <li>
       <a href="">Home Page</a>
    </li>
    <li>
       <a href="">Contact</a>
    </li>
</ul>

But i want to put a <span> element inside every <li> like this:

<ul class="Navigation">
    <li>
        <span>
           <a href="">Home Page</a>
       </span>
    </li>
    <li>
        <span>
           <a href="">Contact</a>
        </span>
    </li>
</ul>

Is there any way to do that without using a "partial" solution?

Was it helpful?

Solution

There's no other way, how to change html output from menu view helper (except indentation and <ul> class).

Well, of course, you can write your own menu view helper - extend Zend\View\Helper\Navigation\Menu and override htmlify method: https://github.com/zendframework/zf2/blob/release-2.2.5/library/Zend/View/Helper/Navigation/Menu.php#L472, but I think, partial template is much better and easier solution.

OTHER TIPS

For anyone who is intrested this guy has created a helper doing this job. http://cmyker.blogspot.gr/2012/11/zend-framework-2-navigation-menu-to.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top