I am using Umbraco 8 for the first time and being tripped up a lot vs Umbraco 6/7.
So I am trying to render some images in the _Layout partial view. From a list of items in the root. Document type below.
I used the Query builder in the _Layout.cshtml to end up with the following to iterate over the logos.
@{
var selection = Umbraco.Content(Guid.Parse("92c903b5-4772-48d5-8e16-5238e45c1e36"))
.ChildrenOfType("footerLogo")
.Where(x => x.IsVisible());
}
<ul>
@foreach (var item in selection)
{
<li>
<a href="@item.Url">@item.Name</a>
// I added this code and put a breakpoint in VS2019 to inspect the object
@item
// Using the immediate window, this gave me a full object
@item.GetProperty("Logo").GetValue()
I've tried to access the Url property with
item.GetProperty("Logo").GetValue().Url
but getting exception
cannot convert from 'method group' to 'HelperResult'
I've spent a couple of hours on googling Umbraco 8 image rendering but no luck. Just wondering if someone could give me a pointer on how to get at these values?
Umbraco 8 render image from IPublishedContent
Hey
I am using Umbraco 8 for the first time and being tripped up a lot vs Umbraco 6/7.
So I am trying to render some images in the _Layout partial view. From a list of items in the root. Document type below.
I used the Query builder in the _Layout.cshtml to end up with the following to iterate over the logos.
I've tried to access the Url property with
but getting exception
I've spent a couple of hours on googling Umbraco 8 image rendering but no luck. Just wondering if someone could give me a pointer on how to get at these values?
Many Thanks
Rob
Hi Rob,
Try this:
Thanks,
Alex
Hi Alex,
Worked perfectly! So casting the object type gives you access to the props? Good to know!
Thanks a lot dude
Rob
Hi Rob,
It's always nice to use strongly typed objects, luckily Umbraco has this feature so use it
Thanks,
Alex
Yes, You are always welcome.
is working on a reply...