ZF-7003: Navigation_Menu view helper html render improvement

Issue Type: Improvement Created: 2009-06-13T02:25:22.000+0000 Last Updated: 2012-11-07T21:27:39.000+0000 Status: Resolved Fix version(s): - 1.12.1 (18/Dec/12)

Reporter: Mina R Waheeb (syncer) Assignee: Frank Brückner (frosch) Tags: - Zend_Navigation

  • After1.12.0
  • zf-crteam-priority

Related issues: - ZF-8951

Attachments: - Menu.patch


Hi, The navigation menu render helper, render html (ul, li and a) elements for example:

<pre class="highlight">

            <a class="cssA">Link A</a>
            <a class="cssB">Link B</a>

The renderer use the navigation page CSS class for element A, If we wana styling specific LI element with current configuration its very hard and must use CSS selectors etc.., It can be more easy to achieve if the navigation page CSS class styles the LI element not the A element like below

<pre class="highlight">

            <a>Link A</a>
            <a>Link B</a>

Now its easy to refer to both li and a.



Posted by Robin Skoglund (robinsk) on 2009-06-13T04:26:48.000+0000

So you want a boolean switch in the menu helper for enabling this behaviour (using page CSS classes for LI instead of A)?

Posted by Mina R Waheeb (syncer) on 2009-06-13T10:29:16.000+0000

There is no need to style the A element because you can easy style it by CSS2 selectors (.class a) which currently implement in all the browsers but for backward compatible it would be suitable.

Posted by Robin Skoglund (robinsk) on 2009-10-20T02:25:19.000+0000

I agree.

The only thing that bites me is that I remember there was a reason for styling the A (instead of the LI). That is to say, there was a reason for that design choice, but I can't remember it right now. Will look further into it.

Posted by Wouter E. M. Berben ( on 2009-10-20T02:59:59.000+0000

If you are wondering: I've modified the Zend_View_Helper_Navigation_Menu so it sets the class on the list item element and not the anchor element. It works and doesn't show any defects. For me this isn't any issue, but I would prefer to see the sollution in the original Framework. Thanks.

I believe the design reason is absolute since CSS2.

Posted by Wouter E. M. Berben ( on 2009-10-20T03:17:44.000+0000

I mean absolete, not absolute :) Sorry for that.

Posted by Stéphane (stephane) on 2009-12-05T03:16:47.000+0000

This would be a nice improvement indeed. Did you have the time to look into it Robin?

Posted by Peter Slivka (svestka) on 2010-01-25T06:23:49.000+0000

I've created a small patch for this. Maybe it helps someone, it just use the same class names for LI elements as for the anchors.

Posted by Stéphane (stephane) on 2010-05-12T10:21:48.000+0000

Robin, would it be possible to integrate the patch from Peter? Regarding CSS, we are able to target a child element from a given element:

<pre class="highlight"> A {
  /* my rules */

but not the opposite. At least, would it be possible to have an update on this issue?

Posted by Kai Uwe (kaiuwe) on 2011-04-06T09:05:02.000+0000

For backward compatibility in the HTML output we need (for the moment) a boolean switch. In Version 2 we remove the switch and set the class to the list element. We also improve the whole rendering for all helpers and all elements (ul, li, a, span, …).

Posted by Kai Uwe (kaiuwe) on 2011-06-07T16:22:26.000+0000

I have written some tests and the implementation. For the current major release, there will be a boolean switch.

Posted by Frank Brückner (frosch) on 2012-07-06T10:15:20.000+0000

Patch and unit tests added.

Posted by Rob Allen (rob) on 2012-11-07T21:27:39.000+0000

Applied patch to trunk (25112) and release-1.12 (25113)

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.