Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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
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
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
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
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
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
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
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
is working on a reply...