Note that there are some explanatory texts on larger screens.

plurals
  1. POMvcSiteMap showing root node only
    primarykey
    data
    text
    <p>I am trying to create a multilevel sitemap in MVC3 with DynamicNodeProvider. But only the root nodes are displayed. Please guide me where the problem is in my code. I have defined a class to override GetDynamicNodeCollection like this:</p> <pre><code> public class UserJourneyNavigationProvider : DynamicNodeProviderBase { private List&lt;NavigationGroups&gt; NavigationGroups { get; set; } public UserJourneyNavigationProvider() { } public UserJourneyNavigationProvider(List&lt;NavigationGroups&gt; NavigationGroups) { this.NavigationGroups = NavigationGroups; } public override IEnumerable&lt;DynamicNode&gt; GetDynamicNodeCollection() { // Build value var returnValue = new List&lt;DynamicNode&gt;(); NavigationGroups ng1 = new NavigationGroups(); ng1.CategoryName = "Menu1"; NavigationGroups ng2 = new NavigationGroups(); ng2.CategoryName = "Menu2"; NavigationGroups ng3 = new NavigationGroups(); ng3.CategoryName = "Menu3"; NavigationGroups ng4 = new NavigationGroups(); ng4.CategoryName = "Menu4"; NavigationGroups ng5 = new NavigationGroups(); ng5.CategoryName = "Menu5"; NavigationGroups ng6 = new NavigationGroups(); ng6.CategoryName = "Menu6"; NavigationGroups ng7 = new NavigationGroups(); ng7.CategoryName = "Menu7"; NavigationGroups ng8 = new NavigationGroups(); ng8.CategoryName = "Menu8"; NavigationGroups ng9 = new NavigationGroups(); ng9.CategoryName = "Menu9"; NavigationGroups ng10 = new NavigationGroups(); ng10.CategoryName = "Menu10"; ng1.ChildCategory = new List&lt;NavigationGroups&gt;(); ng1.ChildCategory.Add(ng2); ng1.ChildCategory.Add(ng3); ng1.ChildCategory.Add(ng4); ng5.ChildCategory = new List&lt;NavigationGroups&gt;(); ng5.ChildCategory.Add(ng6); ng5.ChildCategory.Add(ng7); ng5.ChildCategory.Add(ng8); ng7.ChildCategory = new List&lt;NavigationGroups&gt;(); ng7.ChildCategory.Add(ng9); ng7.ChildCategory.Add(ng10); int i = 1; ng1.CategoryId = (i++).ToString(); ng2.CategoryId = (i++).ToString(); ng3.CategoryId = (i++).ToString(); ng4.CategoryId = (i++).ToString(); ng5.CategoryId = (i++).ToString(); ng6.CategoryId = (i++).ToString(); ng7.CategoryId = (i++).ToString(); ng8.CategoryId = (i++).ToString(); ng9.CategoryId = (i++).ToString(); ng10.CategoryId = (i++).ToString(); NavigationGroups = new List&lt;NavigationGroups&gt;(); NavigationGroups.Add(ng1); NavigationGroups.Add(ng5); NavigationLinkGenerator(NavigationGroups, returnValue, "Home"); return returnValue; } private void NavigationLinkGenerator(List&lt;NavigationGroups&gt; navGroups, List&lt;DynamicNode&gt; returnValue, string parentKey) { foreach (NavigationGroups navGroup in navGroups) { DynamicNode node = new DynamicNode(); node.Controller = "Home"; node.Action = "ProcessActionLink"; node.Title = navGroup.CategoryName; node.Description = navGroup.CategoryName; node.ChangeFrequency = MvcSiteMapProvider.ChangeFrequency.Always; node.Key = navGroup.CategoryId; if (!string.IsNullOrWhiteSpace(parentKey)) node.ParentKey = parentKey; if (navGroup.ChildCategory != null &amp;&amp; navGroup.ChildCategory.Count &gt; 0) { NavigationLinkGenerator(navGroup.ChildCategory, returnValue, navGroup.CategoryId); } returnValue.Add(node); } } } </code></pre> <p>In Mvc.sitemap I defined Nodes like this:</p> <pre><code> &lt;mvcSiteMapNode title="Home" controller="Home" action="Index" key="Home"&gt; &lt;mvcSiteMapNode title="" controller="Home" action="ProcessActionLink" dynamicNodeProvider="Business.Layer.UserJourneyNavigationProvider, Business.Layer" /&gt; &lt;/mvcSiteMapNode&gt; </code></pre> <p>And In _Layout.cshtml I have the following code:</p> <pre><code> @Html.MvcSiteMap().Menu(false, true, true) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload