Products

Solutions

Learn More

Partners

Community

Blog

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Getting StartedGetting StartedRunning Razor menu code inside a moduleRunning Razor menu code inside a module
Previous
 
Next
New Post
10/12/2015 6:37 AM
 
Hello,

I'm trying to build a DNN menu into a module I'm developing. Firstly, I'd just like to get the menu code to render using Razor, I can apply CSS later. I've looked at a lot of articles but tried the code from here: http://www.dnnsoftware.com/wiki/ddrmenu-razor-templates (please see relevant code below).

I insert my own Razor templates using RenderPage i.e. @RenderPage(string filepath, params object[] data)
I pass in the Model via the data parameter and retrieve in in the template via PageData, this works fine with my own razor templates, but how can i make this work for the menu code? I assume I need to pass in the Model, but what to pass in? Could someone please give me a hint.

All the best,

Steve


@using DotNetNuke.Web.DDRMenu;
@using System.Dynamic;
@inherits DotNetNuke.Web.Razor.DotNetNukeWebPage

@{ var root = Model.Source.root; }



@helper RenderNodes(IList nodes) {

if (nodes.Count > 0) {



    @foreach (var node in nodes) {

    var cssClasses = new List();

    if (node.First) { cssClasses.Add("first"); }

    if (node.Last) { cssClasses.Add("last"); }

    if (node.Selected) { cssClasses.Add("selected"); }

    var classString = new HtmlString((cssClasses.Count == 0) ? "" :

    (" class=\"" + String.Join(" ", cssClasses.ToArray()) + "\""));



  • @if (node.Enabled) {

    @node.Text

    } else {

    @node.Text

    }

    @RenderNodes(node.Children)



  • }



}

}

@RenderNodes(root.Children)
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Getting StartedGetting StartedRunning Razor menu code inside a moduleRunning Razor menu code inside a module


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.

Content Layout

Subscribe to DNN Digest

Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  

What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out