This project is read-only.

Current Menu Item

Topics: Customizing Orchard
Aug 27, 2012 at 4:49 PM

Let's say you have the following 3 menu items: "Home | Workshops | Info"

When you created a page in Orchard 1.4 with a permalink "info/someinfopage" the system would automatically highlight the 3th menu item because it recognised that "info/someinfopage" was under the "info" menu.

In 1.5 this behaviour stopped as the menu system has been rewritten. I wondered if there was a way to reproduce this. First I started out by making the "info/someinfopage" a child in the navigation of the "info" menu. However, I didn't want to make it a dropdown. I then tried to remove the dropdown effect by css but that was not very clean imho.

I then tried a different way and changed the file "core/shapes/views/MenuItem.cshtml" on line 11 from 

if (requestUrl == modelUrl) {


if ((Model.Href != "/" && Request.Path.Contains(Model.Href)) || (requestUrl == modelUrl)) { 

This worked for me and I got back the effect as in 1.4.

Not sure if this is 100% ok or the right place, but it worked for me.

Aug 28, 2012 at 4:37 AM

That's a regression. Can you please file a bug?

Aug 28, 2012 at 8:14 AM
Edited Aug 28, 2012 at 8:14 AM

Sure, here you go:

Sep 24, 2012 at 10:05 PM

This is not the ideal solution. This new bug was introduced when fixing another one: try to create a page named /foobar and another one /foobarbaz, if you go to /foobarbaz with your code it will put current on /foobar too. 

It doesn't mean it can't be fixed though ;)

Sep 25, 2012 at 7:59 AM

ah yes indeed, you are right. Shows my limited development skills :)

Thnx for the fix