Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Shaun 248 posts 475 karma points
    Apr 28, 2014 @ 13:20

    Reading nodetype when assigning actions to a menu. Umbraco 7

    Hi All

    I can't seem to work out how to read back nodetype data from dynamically created nodes in a custom section tree.

    I'm creating my nodes dynamically. They reference data stored in a seperate table and aren't actual "umbraco" nodes. 

    I'm displaying them using a tree in a new custom section.

    var tree = new Umbraco.Web.Models.Trees.TreeNodeCollection();
    var mynode = CreateTreeNode("1", "-1", queryStrings, "my node");
    mynode.NodeType = "my node type is A";
    var myothernode = CreateTreeNode ("2", "-1", queryStrints, "my other node");
    myothernode.NodeType = "my node type is B";

    This build up my nodes nicely, and I have a multi level tree.However when I try to work out what nodetype I'm looking at as I attach the actions, I get stuck

    protected override Umbraco.Web.Models.Trees.MenuItemCollection GetMenuForModel(string id, FormDataCollection queryStrings)
      //how do I get the nodetype??
      if(nodetype == "foo")
            menu.Items.Add(blah blah blah)

    I've tried looking at the queryStrings, thinking I could put something in there, but I can't see how to add items to a FormDataCollection from my code.

Please Sign in or register to post replies

Write your reply to: