StaticSiteMapProvider Not Detecting Child Node

Jan 13, 2011 at 9:48 PM
Edited Jan 18, 2011 at 1:08 PM
 

Totally digging this project! I've traced my issue beyond mvcsitemap I believe.  Digging through the source, it appears as though mvcsitemap does not override StaticSiteMapProvider.GetChildNodes().  However, StaticSiteMapProvier.GetChildNodes() is only pulling "Export" as a child of Invoices and it completely ignores "Batch".

  <mvcSiteMapNode title="Home" controller="Home" action="Index" >
    <mvcSiteMapNode title="Invoices" controller="Source" action="List" >
      <mvcSiteMapNode title="Export" controller="Source" action="Export" />
      <mvcSiteMapNode title="Batch" controller="Batch" action="Index" >
        <mvcSiteMapNode title="Batch Detail" controller="Batch" action="Detail" />
        <mvcSiteMapNode title="Batch Approval" controller="Batch" action="Approval" />
      </mvcSiteMapNode>
    </mvcSiteMapNode>
</mvcSiteMap>


If I remove "Batch" children, then StaticSiteMapProvider.GetChildNodes() will find both "Export" and "Batch" as children - as defined below.
  <mvcSiteMapNode title="Home" controller="Home" action="Index" >
<mvcSiteMapNode title="Invoices" controller="Source" action="List" >
<mvcSiteMapNode title="Export" controller="Source" action="Export" />
<mvcSiteMapNode title="Batch" controller="Batch" action="Index" />
</mvcSiteMapNode>
</mvcSiteMap>


It is very possible, and likely, I'm missing a key principle in defining sitemaps. For a bit more detail - I am calling into Menu helper and feeding in a template to work with the model it yields.

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MvcSiteMapProvider.Web.Html.Models.MenuHelperModel>" %>
<%@ Import Namespace="MvcSiteMapProvider.Web.Html.Models" %>

<div id="menu">
<div id="menu-cap-left"></div>
<ul>
<%
    SiteMapNodeModelList children = Model.Nodes.FirstOrDefault().Children;
    for (int i = 1; i < Model.Nodes.Count; i++)
    {
        Response.Write(String.Format("<li><a href=\"{0}\">{1}</a></li>", Model.Nodes[i].Url, Model.Nodes[i].Title));
        if (Model.Nodes[i].IsInCurrentPath)
            children = Model.Nodes[i].Children;   
    }     
%>
</ul>
<div id="menu-cap-right"></div>
</div>

<div id="submenu">
<ul>
<% 
    foreach (var node in children)
    {
        Response.Write(String.Format("<li><a href=\"{0}\">{1}</a></li>",node.Url, node.Title));
    }
%>
</ul>
</div>
Edit: Grammar and clarity - wow I was off that day
Jan 17, 2011 at 7:03 AM

What does the call to Menu() look like?

Jan 18, 2011 at 12:42 PM
<%= Html.MvcSiteMap().Menu("StaticMenuTemplate", SiteMap.RootNode, true, true) %>