I am using Umbraco 7.6.3. I see how easy it is to add content picker to a document type. Then under templates, inserting a content picker through on the home template through the UI adds the following...
@Umbraco.Field("contentPicker")
but this only prints out the ID of the content item I picked (i.e. 1079).
What must I add to this razor tag to show the "actual page content", and not just an id? I couldn't figure that out when Umbraco is asking me to insert value on the template....
I'm still pretty new to Umbraco ... took me a while to wrap my head around that one.
While you can find the answers more quickly in the forum (present and past posts) I recommend you pick through the documentation first. Sometimes the answer is right in front of you. You just have to kick it around for a while to get it.
Here's what I use for a Partial View ... should work in a Template too "as is". This will only call a single image though ... there's a foreach loop you'll need to pick up for anything requiring multiple items.
@{
var typedMediaPickerSingle = Model.Content.GetPropertyValue<IPublishedContent>("newsImage");
if (typedMediaPickerSingle != null)
{
<img src="@typedMediaPickerSingle.Url" style="width:200px" alt="@typedMediaPickerSingle.GetPropertyValue("alt")" />
}
}
Images are a little trickier, but the @Umbraco.Field() will for most of the standard stuff.
Just a couple of tips, if you're new to Umbraco, make sure you check out the "compositions" feature in Document Types and definitely look up Archetype. Head over to Umbraco.tv too ... some solid nuggets there ... and Paul Seal's blog Codeshare. He has some great video tutorials ... some pretty advanced stuff too worth checking out.
Thank you Brett for all the tips and rich documentation. I'm also new to Umbraco and will make the rounds of readings. Just in case someone else stumbles across this issue of our render content from ContentPicker, you can try out Jeavon Leopold's project, Umbraco Core Property Value Converters
I was able to do something as simple as this with the installed package...
Getting content with contentpicker2
I am using Umbraco 7.6.3. I see how easy it is to add content picker to a document type. Then under templates, inserting a content picker through on the home template through the UI adds the following...
but this only prints out the ID of the content item I picked (i.e. 1079).
What must I add to this razor tag to show the "actual page content", and not just an id? I couldn't figure that out when Umbraco is asking me to insert value on the template....
I'm still pretty new to Umbraco ... took me a while to wrap my head around that one.
While you can find the answers more quickly in the forum (present and past posts) I recommend you pick through the documentation first. Sometimes the answer is right in front of you. You just have to kick it around for a while to get it.
Here's what I use for a Partial View ... should work in a Template too "as is". This will only call a single image though ... there's a foreach loop you'll need to pick up for anything requiring multiple items.
Images are a little trickier, but the
@Umbraco.Field()
will for most of the standard stuff.Just a couple of tips, if you're new to Umbraco, make sure you check out the "compositions" feature in Document Types and definitely look up Archetype. Head over to Umbraco.tv too ... some solid nuggets there ... and Paul Seal's blog Codeshare. He has some great video tutorials ... some pretty advanced stuff too worth checking out.
Good luck.
Thank you Brett for all the tips and rich documentation. I'm also new to Umbraco and will make the rounds of readings. Just in case someone else stumbles across this issue of our render content from ContentPicker, you can try out Jeavon Leopold's project, Umbraco Core Property Value Converters
I was able to do something as simple as this with the installed package...
Hopefully this bit of information will save the next person tons of time from searching for a related situation.
is working on a reply...
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.
Continue discussion