Issues

ZF-7927: Add ability to wrap label during htmlify in Zend_View_Helper_Navigation_Menu

Issue Type: New Feature Created: 2009-09-22T15:33:58.000+0000 Last Updated: 2013-01-22T10:09:05.000+0000 Status: Closed Fix version(s): Reporter: Joe Gornick (jgornick) Assignee: Frank Brückner (frosch) Tags: - Zend_Navigation

Related issues: Attachments:

Description

The reason why I'd like to see the option to wrap the label with an element is because when a user is trying to style their navigation menu output with image sprites, currently, you would need JavaScript to remove the innerHTML from the element to hide the label.

Here's a link to the same technique I'm using on my sites: http://stylemeltdown.com/2007/10/…

Notice the element inside the element. This is an advantage because you can use CSS to hide the span and it still allows the content to be indexed and used with screen readers.

It would be nice to be able to specify an option which allows me to wrap the label. Specifically, it would be nice if I could just say array('labelWrapper' => 'span') or something much like that.

Comments

Posted by Dolf Schimmel (Freeaqingme) (freak) on 2009-09-24T17:35:17.000+0000

Assigning this issue to Robin Skoglund as he's the maintainer (and creator) of Zend_Navigation.

Posted by Joe Gornick (jgornick) on 2009-11-25T10:44:24.000+0000

Robin, thoughts on this?

Posted by Robin Skoglund (robinsk) on 2009-11-25T10:53:11.000+0000

My thoughts: the rendering might be changed to some sort of decorators for ZF 2.0. This issue might be related to ZF-7003. Maybe I (or someone else) should create a wiki page for Zend_Navigation 2.0 to gather feedback and thoughts on changes/improvements.

Posted by Joe Gornick (jgornick) on 2009-11-25T11:49:08.000+0000

Robin, thanks for the prompt response!

Decorators for 2.0 sounds like a great idea! That would give complete control of the output produced by the view helpers. I can dig it.

In the meantime, the output produced by view helper is sufficient for most use cases, however, in a situation when you want to apply background images to a link and hide the text, this is where it is limited. I think what I'm trying to ask for is a poor mans attempt at a decorator. However, this decorator only affects the label.

Another example could look like:

$this->navigation()->menu(null, array( 'labelWrapper' => array( 'element' => 'span', 'class' => 'label-span' ) );

That would then wrap the label with a span element and add the class of label-span. Any other options you supply would be translated to attribute on the wrapper element.

Just trying to brainstorm here. Maybe for now, I can simply write my own navigation menu view helper that add the ability, but I think we should discuss the idea of adding decorators of some sorts to the navigation view helpers in ZF 2.0.

Thanks!

Posted by Hector Virgen (djvirgen) on 2010-06-01T16:04:25.000+0000

I agree and also need an inner for styling purposes. I've tried using Javascript to inject spans inside of the anchors, but this breaks for non-JS browsers.

I've also tried providing my own view helper that extends Zend_View_Helper_Navigation_Menu to overload the htmlify() method, but my helper is not being picked up. I believe this is because the navigation helper adds its helper path to the end of the stack instead of the beginning. Since the helper paths are LIFO, it finds the built-in ZF helper instead of using mine.

Posted by Frank Brückner (frosch) on 2012-04-05T14:20:00.000+0000

I think we will wait for the implementation of rendering in Zend_Form 2.0 and then we adapt this for the navigation view helpers.

Posted by Frank Brückner (frosch) on 2013-01-22T10:09:05.000+0000

This is a task for version 2.5 or 3.

Have you found an issue?

See the Overview section for more details.

Copyright

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

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

Contacts