Helper to generate horizontal menus

Aug 13, 2010 at 7:51 PM

The Menu and Submenu helpers seem to give only children of the current node or a node lower. It doesn't seem like there is a way to get a "top level" menu, i.e. all the level 1 nodes, or an arbitrary level such as 2. Am I wrong?

<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" enableLocalization="true">
  <mvcSiteMapNode title="Home" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal">
      <mvcSiteMapNode title="Security" area="Security" controller="Authentication" action="Index">
        <mvcSiteMapNode title="A" area="Security" controller="Authentication" action="A" />
        <mvcSiteMapNode title="B" area="Security" controller="Authentication" action="B" />
        <mvcSiteMapNode title="C" area="Security" controller="Authentication" action="C" />
      </mvcSiteMapNode>
      <mvcSiteMapNode title="Options" area="Options" controller="Options" action="Options"/>
      <mvcSiteMapNode title="Help" area="Help" controller="Help" action="Help"/>
      <mvcSiteMapNode title="Reports" area="Reports" controller="Reports" action="Reports"/>
  </mvcSiteMapNode>
</mvcSiteMap>
If I am at /Security/Authentication/A
In this I would want for main menu:
  • Security
  • Options
  • Help
  • Reports
And for level 2 menu:
  • A
  • B
  • C
Coordinator
Aug 16, 2010 at 1:53 AM

This *should* be possible with one of the many overloads of Menu(). If not, feel free to post again so we can get this feature in.

Aug 16, 2010 at 11:49 AM
I tried every overload of Menu and Submenu and could not generate this result. These helpers seem to begin at the current code, and work down, so there is not way to reference higher nodes in the heirarchy. The behavior I was expecting for Menu was to give a node level, and it generates a list of nodes at that level from the sitemap relative to the node I am on. Maybe a new helper is required for this behavior?
Aug 16, 2010 at 11:52 AM
Thanks, I did post a response as I have not been able to produce the desired result.



From: "maartenba" <notifications@codeplex.com>
Sent: Sunday, August 15, 2010 9:54 PM
To: jeff@jorczak.com
Subject: Re: Helper to generate horizontal menus [mvcsitemap:223523]

From: maartenba

This *should* be possible with one of the many overloads of Menu(). If not, feel free to post again so we can get this feature in.


Coordinator
Aug 18, 2010 at 1:59 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.