Razor: get child pages

Aug 10, 2015 at 4:50 PM
Looking to build a simple razor template that will show child pages of the current page, and an icon if one is present in the page settings. Does anyone have an example of using Razor in a 2sxc template to render page navigation?
Sep 9, 2015 at 7:27 AM
Why do you want to do this with 2sxc and not ddrmenu

Armand
2DNN
Sep 14, 2015 at 8:32 PM
To make it easier for the admin to just drop a menu on a page, rather than filling out the confusing parameters of the DDR module settings.
Sep 14, 2015 at 9:19 PM
have you tried looking for a ddr menu tempalte razor and implement that?
Sep 14, 2015 at 10:07 PM
IF you drop a DDR menu module on a page, use the ULTokens template, and spend 15-20 minutes playing with the settings, you'll master it in no time. Then, you can move to the Razor templates and begin to work your magic. Take a look at http://www.dnnsoftware.com/wiki/ddrmenu-razor-templates,

Also, the DumpXML template will show you exactly what is available to the template.

About the only potentially confusing parmater for DDR is the Node Selection Expression. use the ULTokens or DumpXML with various forms of that to see how DDR works.

Sep 15, 2015 at 2:31 PM
Sep 16, 2015 at 6:46 PM
Got it. I've done it before as well, just want to use 2sxc for everything.
Sep 21, 2015 at 10:56 AM
Edited Sep 21, 2015 at 11:29 AM
You are in luck I just needed it for my own so here you go :
@using DotNetNuke.Entities.Tabs

@functions {

    public List<DotNetNuke.Entities.Tabs.TabInfo> getChildTabs(int parId)
    {
        List<DotNetNuke.Entities.Tabs.TabInfo> tabs = TabController.GetTabsByParent(parId, 0).FindAll(
         delegate(DotNetNuke.Entities.Tabs.TabInfo tab)
         {
             return tab.IsVisible && !tab.IsDeleted;
         }
        );
        return tabs;
    }
}
sample use
@{
   
    var childTabs = getChildTabs(254);
}


@foreach (var t in childTabs)
{

    <p>@t.TabName</p>
}

and for your case you can just use the dnn objects from razor so instead of 254 you use
Dnn.Portal.ActiveTab.TabID
Armand Datema
2DNN
Your friendly non official 2sxc support :)
Sep 22, 2015 at 4:49 PM
Very cool sir.

Thanks for sharing