Copied to clipboard

Flag this post as spam?

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


  • Simon Dingley 1431 posts 3332 karma points c-trib
    Feb 26, 2013 @ 10:52
    Simon Dingley
    0

    DynamicNode passed to helper results in ability to access node properties

    I have a problem that involves MNTP which returns CSV data and ahelper that renders node data. When the DynamicNode is passed into the helper I lose access to the properties and not sure why as I can step into the script and access properties fine before it passed in?

    @{
        var panels = Model._SidebarContent.Split(',');
    
        foreach (var panel in panels)
        {
            var node = Model.NodeById(panel);
            string nodeType = node.NodeTypeAlias;
    
            switch (nodeType)
            {
                case "ExampleNodeType":
          // Properties accessible via dot notation here e.g. Node.Myproperty
                    @ExampleRenderNodeTypeHelper(node) 
                    break;
            }
        }
    }
    @helper ExampleRenderNodeTypeHelper(dynamic contentNode)
    { // Properties no longer accessible since contentNode is considered an 'object' type now? @contentNode.MyProperty }

    I'm using Umbraco 4.11.4 and not experienced this before. The only thing I am doing different to what I normally do is returning CSV data from the MNTP instead of XML.

  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    Feb 26, 2013 @ 10:57
    Lee Kelleher
    0

    Hi Simon,

    Could it be that the parameter type should be a DynamicNode?

    @helper ExampleRenderNodeTypeHelper(DynamicNode contentNode)

    Cheers, Lee.

  • Simon Dingley 1431 posts 3332 karma points c-trib
    Feb 26, 2013 @ 11:00
    Simon Dingley
    0

    I've already tried that and it results in the following:

    'umbraco.MacroEngines.DynamicNode' does not contain a definition for 'MyProperty' and no extension method 'MyProperty' accepting a first argument of type 'umbraco.MacroEngines.DynamicNode' could be found (are you missing a using directive or an assembly reference?)
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies