Copied to clipboard

Flag this post as spam?

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


  • Tom Maton 387 posts 660 karma points
    Apr 22, 2015 @ 10:10
    Tom Maton
    0

    Get node details from content picker in macro added to page via RTE

    Hi All,

    It's been a very long time since I've last used Umbraco so apologies for silly questions but...

    I've got a Macro being added via a RTE and rendering on the page as expected.

    In the Macro, I've got a content picker, I now want to get the details from the selected node in the content picker.

    I cant for the life of me remember how to do this.

    Thanks in advance.

    I'm on 7.2.2

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Apr 22, 2015 @ 10:15
    Dennis Aaen
    1

    Hi Tom,

    Take a look at the documentation on how to get data from a content picker in Umbraco 7.

    https://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/Built-in-Property-Editors-v7/Content-Picker

    Hope this helps,

    /Dennis

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Apr 22, 2015 @ 10:19
    Jan Skovgaard
    100

    Hi Tom

    You can use @Model.MacroParameters["paramAlias"] to get the value - It's the same whether you're using dymaic or strongly typed.

    Then you can use either @Umbraco.TypedContent(id) (Strongly typed) or @Umbraco.Content(id) (Dynamic).

    So you should be able to write something like this when using strongly typed

    @{
       var idFromParam = @Model.MacroParameters["yourId"];
       var item = @Umbraco.TypedContent(idFromParam);
    }
    
    @item.GetPropertyValue("header")
    

    It's always a good idea to have this reference nearby when dealing with Razor btw :) https://our.umbraco.org/projects/developer-tools/umbraco-v6-mvc-razor-cheatsheets

    I hope this helps!

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft