This project is read-only.

2 Menu Widgets on 1 page - Using different structure/styles? (menu.cshtml)

Topics: Administration, Core, Customizing Orchard, General, Writing themes
Apr 24, 2014 at 2:25 PM
A while ago I was asking about changing the way Orchard displays menus. After a while I came up with this answer here which is basically overwriting the default display by creating a Menu.cshtml in my theme directory.

Now I've run into a new problem:
In the footer of my website I want to have a couple of links, as seen on many modern websites (,, etc.). However the DOM structure of the main navigation menu is fundamentally different from the menu I want to display in the footer (simply overwriting the CSS is not enough due to some JS scripts interacting with the main menu).

(For the sake of simplicity we can just treat this problem as:
"The 1st menu should output an unordered list, while the 2nd menu should be <div>s within <p>s.")

So the question is: How can I specify an alternative "Footer-Menu.cshtml" and make the Menu Widget in the Footer use that instead of the normal Menu.cshtml?

Any help much appreciated!
Apr 25, 2014 at 8:14 AM
If you are using widgets, create a Menu Widget named TestWidget and an alternate for it: Widget-Name-TestWidget.cshtml. There you can write your footer menu the same way as the first one.
Apr 25, 2014 at 9:09 AM
Thank you for your answer, alternates are a concept I was not aware of until now.
While using the alternate for the widget (Widget-Name-FooterMenu.cshtml in this case) worked technically (the content of the alternate was shown), it didn't call the actual navigation. I tried using the code from the original Menu.cshtml in the WIdget-Name-FooterMenu.cshtml for testing, but it failed to show the navigation.

I tried to create an alternate for the Menu directly instead of the widget by creating a Menu-Name-FooterMenu.cshtml, which failed. The navigation doesn not have a name attibute, only a title attribute. I tried Menu-Title-FooterMenu.cshtml but it is not triggered, neither is a Menu-Zone-Footer.cshtml.

You can see that I'm merely testing around here, I still lack a lot of understanding how the alternate method is supposed to work.

Could you please try and explain to me:
Either, how to create an alternate for the Menu, not the Widget?
Or, how the alternate for the Widget must be coded so that it does call the Navigation and uses an alternate Template for it then?

Thank you for your time, much appreciated!
Apr 25, 2014 at 10:17 AM
If you are using widget, you can use this to get menuitems

foreach (var item in Model.Content.Items[0].Menu.Items)
Marked as answer by Konadi on 4/25/2014 at 2:29 AM
Apr 25, 2014 at 10:31 AM
That did the trick, thank you very much!

Just out of curiosity, is there a way to directly use an alternate for Menu.cshtml or does that collide with Orchard's method/system/workflow?
Apr 28, 2014 at 12:40 PM
Edited Apr 28, 2014 at 12:42 PM
I just noticed something: using the approach I marked as solution will give you "internal" urls for your links, while the main menu outputs the "permalink" set in the content item.

For example the item with the href
will show as a link to
which is bad not only for aesthetic reasons; search engines will see it as douplicate content.

Is there a way to "convert" the internal href value into the associated permalink?

Thank you.