This project is read-only.

HTML menu item - hooking into selected page

Topics: Customizing Orchard
Nov 19, 2012 at 12:04 PM
Edited Nov 19, 2012 at 4:39 PM

Hi I have created a new navigation menu here, after upgrading to Orchard 1.6.

I used the HTML menu item options when creating the menu.

The menu items seem to render fine, but I don't seem to be able to identify which menu item's page I'm currently on.

The last menu item "test" is of type "Content Menu item" and as you can see it gives the li tag of the selected page a class name of "current" which I can then use to style the menu.

This doesn't happen with HTML menu items though.

Anyone know how I can work around this?

Nov 23, 2012 at 3:33 AM

Yes, a workaround is to use content menu items ;) If you need custom markup for a specific item, you can either write your own item type, or you can have a template alternate.

Nov 23, 2012 at 9:52 AM

Thanks for your response.

I'm sorry, but again I don't understand your workarounds you're proposing for 'custom markup'.

I can select a "content item" for  "Content Menu Item", but this seems to be for the destination, not the markup for the link. 

I need this custom html functionality for a drop down menu. Are you proposing that I write that markup into the dom below somewhere and use Javascript on hover or something.

How can I achieve this?

Nov 26, 2012 at 10:16 PM

No, you can write your own menu item type, which would be some sort of hybrid between custom items and content menu items. Look at the code for those two as a starting point. David Hayden has a post about this on his blog.