Copied to clipboard

Flag this post as spam?

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


  • Rocoeh 65 posts 86 karma points
    Jun 20, 2012 @ 11:49
    Rocoeh
    0

    Getting fields from specific conent node

    Hi,

    I know I can get all by type and then list them out but I am trying to get a specif fileld from a specif node. So if my node is 1703 and my field is shortIntro how do I return this in another template?

  • gilad 185 posts 425 karma points
    Jun 20, 2012 @ 11:56
    gilad
    1

    Hi rocoeh.

    You can make a dynamic object like this:

    dynamic node = new umbraco.MacroEngines.DynamicNode(1703);

    Then you can get all properties like this : 

    <h2>@node.shortIntro </h2>

    You can also make a DynamicNode then get properties like this :

    DynamicNode node = new  umbraco.MacroEngines.DynamicNode(1703);
    <h2>@node.GetPropertyValue("shortIntro")</h2>

    Cheers.

  • Rocoeh 65 posts 86 karma points
    Jun 20, 2012 @ 12:08
    Rocoeh
    0

    Thanks for your reply, my code

     

    <umbraco:Macro runat="server" language="cshtml">
    @{
    DynamicNode node = new  umbraco.MacroEngines.DynamicNode(1703);
    <h2>@node.GetPropertyValue("shortIntro")</h2>
      }
    </umbraco:Macro>
     

    The error is

     

    Error loading MacroEngine script (file: )


  • gilad 185 posts 425 karma points
    Jun 20, 2012 @ 12:14
    gilad
    0

    Hi,

    Add this:

    @using umbraco.MacroEngines;

    like this:

    <umbraco:Macro runat="server" language="cshtml">
    @using umbraco.MacroEngines; 
    @{
    DynamicNode node = new DynamicNode(1703);
    <h2>@node.GetPropertyValue("shortIntro")</h2>
      }
    </umbraco:Macro>

    Or just add umbraco.MacroEngines also for first DynamicNode :

     

    <umbraco:Macro runat="server" language="cshtml">
    @{
      umbraco.MacroEngines.DynamicNode node = new umbraco.MacroEngines.DynamicNode(1703);
    <h2>@node.GetPropertyValue("shortIntro")</h2>
    }
    </umbraco:Macro>

     

     


  • Rocoeh 65 posts 86 karma points
    Jun 20, 2012 @ 12:16
    Rocoeh
    0

    first one worked a treat, many thanks!

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Jun 20, 2012 @ 13:06
    Michael Latouche
    0

    Hi Rocoeh,

    Can you mark gilad's post as the answer, so that others facing the same problem might find it easily?

    Many thanks!

    Cheers,

    Michael.

Please Sign in or register to post replies

Write your reply to:

Draft