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
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"))
.Where(x => x.IsVisible());
@foreach (var item in selection)
// I added this code and put a breakpoint in VS2019 to inspect the object
// Using the immediate window, this gave me a full object
I've tried to access the Url property with
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?
var imageUrl = item.Value<IPublishedContent>("Logo").Url;
Worked perfectly! So casting the object type gives you access to the props? Good to know!
Thanks a lot dude
It's always nice to use strongly typed objects, luckily Umbraco has this feature so use it
Yes, You are always welcome.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted