Search code examples
razordotnetnuke

In Razor select a IList<MenuNode> of nodes by a ParentId or TabId in DNN7


Using DNN7 and trying to write a DDR Menu in Razor, My Menu Tree can be at time 5 Levels deep and wanted to know if there was a way to access a list of nodes by just passing a TabId or ParentId?

Any help would be appreciated.


Solution

  • Ok so figured it out should anyone else need this

    @using DotNetNuke.Web.DDRMenu;
    @using System.Dynamic;
    @using DotNetNuke.Entities.Tabs;
    
    @inherits DotNetNuke.Web.Razor.DotNetNukeWebPage<dynamic>
    @{ 
        var tabs = TabController.GetTabsByParent(TabController.CurrentPage.TabID, TabController.CurrentPage.PortalID);
    }
    
    @RenderNodes(tabs)
    
    @helper RenderNodes(IList<TabInfo> nodes)
    {
        foreach (var t in nodes)
        {
            <div class="listing-repeater row">
                <div class="span17 listing-item">
                    <h3>
                        <a href="@t.FullUrl">@t.TabName</a>
                    </h3>
                    <p>
                        <a href="#">@t.Description</a>
                    </p>
                </div>
                <div class="span1">
                    <span>
                        &rsaquo;
                    </span>
                </div>
            </div>
        } 
    }