laminas-navigation icon indicating copy to clipboard operation
laminas-navigation copied to clipboard

Menu view helper: Can't set class on li and a elements

Open weierophinney opened this issue 6 years ago • 10 comments

when working with bootsrap4 it is not enough to set class on ul element. Maybe add methods like setULClass for li and a?


Originally posted by @svycka at https://github.com/zendframework/zend-navigation/issues/76

weierophinney avatar Dec 31 '19 22:12 weierophinney

You can add the classes to the li element instead of the a element or you can use a partial script. The last option should help you.

At the moment we will not add more methods to the view helper, because we will rework and simplify the whole rendering of the helpers.


Originally posted by @froschdesign at https://github.com/zendframework/zend-navigation/issues/76#issuecomment-398614344

weierophinney avatar Dec 31 '19 22:12 weierophinney

@froschdesign yes I could but look https://getbootstrap.com/docs/4.0/components/navbar/#supported-content

<ul class="navbar-nav mr-auto">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home</a>

all ul, li and a has to have a custom class and if I change from a to li this still not help. And yes I can use a partial script(that's what I do now), but that's annoying because I have to manage active page acl and everything myself I haven't tested yet other helpers but they may have problems as well


Originally posted by @svycka at https://github.com/zendframework/zend-navigation/issues/76#issuecomment-398628568

weierophinney avatar Dec 31 '19 22:12 weierophinney

@froschdesign when this could happen I guess not any time soon?


Originally posted by @svycka at https://github.com/zendframework/zend-navigation/issues/76#issuecomment-398629438

weierophinney avatar Dec 31 '19 22:12 weierophinney

@svycka I know the Bootstrap "Navbar" and all the classes.

…I haven't tested yet other helpers but they may have problems as well

Please keep in mind zend-navigation was developed and released before Bootstrap or Foundation had a first release.

…but that's annoying because I have to manage active page acl…

It's very simple.

when this could happen I guess not any time soon?

Why are you so pessimistic? We are already working on it! (zend-expressive support first, then the rework of the view helpers) In the meantime, I would extend the view helper, then you do not need a partial script.


Originally posted by @froschdesign at https://github.com/zendframework/zend-navigation/issues/76#issuecomment-398632245

weierophinney avatar Dec 31 '19 22:12 weierophinney

I am not pessimistic just know that zend-* has a lot of projects and only a few people to work on them.


Originally posted by @svycka at https://github.com/zendframework/zend-navigation/issues/76#issuecomment-398636135

weierophinney avatar Dec 31 '19 22:12 weierophinney

Hello. Are there any update on this ? Going through tutorial and stucked in the same trouble - still no ability to set li and a classes, have to use partial template.

sologub-s avatar May 22 '20 20:05 sologub-s

Hello Everyone is There any Update on this ? or a way ? could anyone share an example. it's 2021 still couldn't find any soluton :-(

gitAasharAzeem avatar Jan 26 '21 14:01 gitAasharAzeem

@Aawshirazeem

…could anyone share an example. it's 2021 still couldn't find any soluton

Use a partial to create a custom HTML output.

froschdesign avatar Jan 26 '21 14:01 froschdesign

I tried custom Html output, But with Partial I couldn't able to set class to tag. Is there any example that could help. Thank You

gitAasharAzeem avatar Jan 27 '21 08:01 gitAasharAzeem

@Aawshirazeem

I tried custom Html output, But with Partial I couldn't able to set class to tag.

You can add additional parameters to a partial script. See: https://docs.laminas.dev/laminas-navigation/helpers/menu/#using-additional-parameters-in-partial-view-scripts


Please keep in mind this is not a support forum. For further questions, please use our forums. Add your use case and a code example and I will help you. Thank you!

froschdesign avatar Jan 27 '21 08:01 froschdesign