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
The code below displays 5 items rather than 6 that I need. When I change this to 7 it displays 6 so it displays one less than specified. Just can not work out why it is doing this. Does anyone have any ideas.
@inherits Umbraco.Web.Macros.PartialViewMacroPage @{ var selection = Umbraco.Content(Guid.Parse("800fd6f3-d5c1-498b-9e81-0dac67a85d7d")) .Children() .Where(x => x.IsVisible()) .OrderByDescending(x => x.Value<DateTime>("pressReleaseDate")) .Take(6); } @foreach (var item in selection) { var typedMediaPickerSingle = item.Value<IPublishedContent>("pressReleasehomeimage"); if (typedMediaPickerSingle != null) { <div class="main-news"> <div class="newsbody"> <div class="newsimage"><img src="@typedMediaPickerSingle.Url" /></div> <div class="newstext"> <h7> @(item.Value<DateTime>("pressReleaseDate").ToString("dddd, MMMM dd, yyyy"))</h7> <div class="truncate-ellipsis"> <h5><a href="@item.Url">@item.Name</a></h5> </div> </div> </div></div> <div class="newsfooter"><img src="umbraco/assets/img/pressimage.png"></div> } }
Hi, Can you confirm that non of the items of your selection don't have a null "pressReleasehomeimage" ?
Thanks Thomas All items have images.
Hmm not sure, maybe you can try also to amend the where with that
.Where(x => x.IsVisible() && x.Value<IPublishedContent>("pressReleasehomeimage") != null)
Just to make sure isn't any image. Can't see anything else.. :/
Thanks Thomas We found that one of the images was formatted in cmyk and not rgb. When we made it rgb it worked.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Rendering display issue with .Take
The code below displays 5 items rather than 6 that I need. When I change this to 7 it displays 6 so it displays one less than specified. Just can not work out why it is doing this. Does anyone have any ideas.
Hi, Can you confirm that non of the items of your selection don't have a null "pressReleasehomeimage" ?
Thanks Thomas All items have images.
Hmm not sure, maybe you can try also to amend the where with that
Just to make sure isn't any image. Can't see anything else.. :/
Thanks Thomas We found that one of the images was formatted in cmyk and not rgb. When we made it rgb it worked.
is working on a reply...