Display properties from content selected via "Content Picker" data type
Hello, I'm trying use the content picker data type on a page and then display custom properties from the selected content on that page. In this particular case I have an image in the selected content that I'm trying to display but it looks as though I only have access to ".Url" and ".Name" when reading the documentation.
Is it possible to display custom properties on these items?
Here's my set up:
var author = Umbraco.TypedContent(CurrentPage.author);
var authorImageId = Umbraco.Media(author.avatar);
var authorImageUrl = authorImageId.umbracoFile;
Hey Jeavon, thanks for your quick reply on this. I've tried this and get this error:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])'
Line 77: var author = Umbraco.Content(CurrentPage.author);
Line 78: var authorImageId = Umbraco.Media(author.avatar);
Line 79: var authorImageUrl = authorImageId.umbracoFile;
Actually, nevermind. I had the content named the same as one of my members and had actually chosen the member instead of the content. Thanks for your help.
var author = Umbraco.Content(CurrentPage.author);
<p>@author.avatar</p>
if (author.HasValue("avatar"))
{
var authorImageId = Umbraco.Media(author.avatar);
var authorImageUrl = authorImageId.umbracoFile;
}
Display properties from content selected via "Content Picker" data type
Hello, I'm trying use the content picker data type on a page and then display custom properties from the selected content on that page. In this particular case I have an image in the selected content that I'm trying to display but it looks as though I only have access to ".Url" and ".Name" when reading the documentation.
Is it possible to display custom properties on these items?
Here's my set up:
Hi Brian,
You are using the dynamic model (CurrentPage) so you need to use the dynamic Content method instead of the typed TypedContent method.
e.g.
Jeavon
Hey Jeavon, thanks for your quick reply on this. I've tried this and get this error:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])'
Line 77: var author = Umbraco.Content(CurrentPage.author); Line 78: var authorImageId = Umbraco.Media(author.avatar); Line 79: var authorImageUrl = authorImageId.umbracoFile;
Do you see anything else wrong?
Thanks!
Actually, nevermind. I had the content named the same as one of my members and had actually chosen the member instead of the content. Thanks for your help.
Could you try this:
is working on a reply...