Skip to content

Instantly share code, notes, and snippets.

@valadas
Last active November 24, 2024 17:44
Show Gist options
  • Save valadas/bc22474153ac5e380158f038af46ab6a to your computer and use it in GitHub Desktop.
Save valadas/bc22474153ac5e380158f038af46ab6a to your computer and use it in GitHub Desktop.
DDR Menu to export pages

This is a DDR Menu template to export a text format of a DNN site pages to reuse in the "Create Multiple Pages" feature on another site.

<?xml version="1.0" encoding="utf-8" ?>
<manifest>
<template>pagelist.cshtml</template>
</manifest>
@using DotNetNuke.Web.DDRMenu;
@using System.Dynamic;
@inherits DotNetNuke.Web.Razor.DotNetNukeWebPage<dynamic>
<nav id="main-menu">
@RenderPages(Model.Source.root.Children)
</nav>
@helper RenderPages(IEnumerable<MenuNode> pages)
{
if (!pages.Any())
{
return;
}
foreach (var page in pages)
{
@page.Text<br />
if (page.HasChildren())
{
@RenderSubs(page.Children);
}
}
}
@helper RenderSubs(IEnumerable<MenuNode> pages)
{
foreach (var page in pages)
{
var chevrons = string.Empty;
for (int i = 0; i < page.Depth; i++)
{
chevrons += ">";
}
@[email protected]<br />
if (page.HasChildren())
{
@RenderSubs(page.Children);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment