callumbwhyte / meganav

A flexible, draggable link picker for constructing site navigation menus in Umbraco
MIT License
35 stars 34 forks source link

Feature request - ability to add additional field for class names for each item #22

Closed blachawk closed 6 years ago

blachawk commented 6 years ago

It would be wonderful if editors in Umbraco had the opportunity to include an optional class name for each item in meganav. For each item in meganav, we currently have the option of adding a...

All I want to do is also add the ability to....

Is this something we can easily implement into the package?

My end goal is to have cool stuff like...

<ul>
<li class="facebook"><a href="www.facebook.com">facebook</a></li>
<li class="twitter"><a href="www.twitter.com">twitter</a></li>
</ul>

or.....

<a class="facebook" href="www.facebook.com">facebook</a>
<a class="twitter" href="www.twitter.com">twitter</a>

Thanks!

blachawk commented 6 years ago

Ok, I have one solution that works today. I can check the Title value for each item within a foreach loop. And depending on that value, I can create a custom class name on an attribute. This is probably the easiest way to do it OOTB.

Something like this...

<a href="@item.Url" @(item.Title == "Privacy Policy" ? "class=privacy" : "class=ext")>@item.Title</a>

This process will work, as long as class names is 'predefined' by the developer. But it would be nice if the editor can create one on the fly. Then all I have to do is update my CSS style-sheet with any branding needs.

Thanks!

callumbwhyte commented 6 years ago

Thanks for raising this feature request!

I am happy to say there is currently a pull request pending (#15) that will allow you to add any number of custom properties to your Meganav items, including a textfield which could be used to supply the CSS class for your menu item.

In the mean time, the solution you have found by checking against properties returned by the Meganav is unfortunately the best way.

Hope this helps, and thanks again for using the package!