I'm hoping this is as easy as the title suggests :)
I currently have a page (event) that has a multi-node picker called "associated". it allows users to select content from the site that is associated with an event.
For each event I want to be able to show all the associated content on a sidebar.
I want to be abel to display : Name/ URL/ Image
I can get name and URL quite easily but i'm finding it hard to access any of the other properties for the associated content.
Heres my code:
@using umbraco.MacroEngines;
@using Fact.Classes;
@using Umbraco.Core.Models;
@inherits umbraco.MacroEngines.DynamicNodeContext
Array associatedIds = Model.associated.ToArray();
foreach (DynamicNode n in associatedIds)
{
<div class="large-12 columns">
<div class="large-4 columns">
<a href="@n.Url">
<img src="@n.backgroundImage" alt="@n.Name" />
</a>
</div>
<div class="large-8 columns">
<a href="@n.Url">
<h4>@n.Name</h4>
</a>
</div>
</div>
}
The alias of the property I am trying to select is : backgroundImage. But i cant select it. And when i do put it in i get an error:
Is there any way to access the media of an associated content item?
Accessing properties
Hi Guys,
I'm hoping this is as easy as the title suggests :)
I currently have a page (event) that has a multi-node picker called "associated". it allows users to select content from the site that is associated with an event.
For each event I want to be able to show all the associated content on a sidebar.
I want to be abel to display : Name/ URL/ Image
I can get name and URL quite easily but i'm finding it hard to access any of the other properties for the associated content.
Heres my code:
@using umbraco.MacroEngines;
@using Fact.Classes;
@using Umbraco.Core.Models;
@inherits umbraco.MacroEngines.DynamicNodeContext
Array associatedIds = Model.associated.ToArray();
foreach (DynamicNode n in associatedIds)
{
<div class="large-12 columns">
<div class="large-4 columns">
<a href="@n.Url">
<img src="@n.backgroundImage" alt="@n.Name" />
</a>
</div>
<div class="large-8 columns">
<a href="@n.Url">
<h4>@n.Name</h4>
</a>
</div>
</div>
}
The alias of the property I am trying to select is : backgroundImage. But i cant select it. And when i do put it in i get an error:
Is there any way to access the media of an associated content item?
Hi James,
What if you do something like this would this work.
Hope this helps,
/Dennis
Hi Dennis,
Thanks for the response. This doesnt seemed to have worked :(
It's a tricky one.
Hi James,
Okay what if you do:
Hope this helps,
/Dennis
Still nothing. I'm trying a few different things. Thanks for your input so far.
Everything else loads [email protected] + @n.Url
Thanks for the help. Problem is solved.
var imageUrl = fm.GetImageFromMedia(n, "backgroundImage");
@imageUrl.ImageURL
This worked.
Thanks for your help and response.
is working on a reply...