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
Hi guys :-)
I'm trying to output my blogposts from a partial view to frontpage. However i only want to show the lastest three posts.
It seems like it should be very easy, however I cant seem to figure it out. Maybe you can help me?
Heres my partial view code:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{ var selection = Model.Content.Site().FirstChild("portfolio").Children() .Where(x => x.IsVisible()) .OrderBy("CreateDate desc"); }
@foreach(var item in selection){ <div class="flex-wrapper"> <div class="flex-item"> @{ var postImage = item.GetPropertyValue<IPublishedContent>("specificProjectMainImage"); if (postImage != null) { <img src="@postImage.Url" style="width: 100%;" alt="@postImage.GetPropertyValue("alt")" /> } } </div> <div class="flex-item blogItemText"> <h2>@item.GetPropertyValue("specificProjectTitle")</h2> <p>@item.GetPropertyValue("specificProjectTeaser")</p> <a href="@item.Url">Se projekt</a> </div> </div> }
Please tell if my question is unclear to you.
Best regards Lasse
Hi Lasse
What about this, off the top of my head this may help, or at least point you in the right direction
Model.Content.Site().FirstChild("Portfolio").Children.Where(x=>x.IsVisible()).OrderBy("CreateDate").Take(3)
Notice the addition of .Take(3)
WUHUUU L1ca! It works like a dream! :-) Thank you so much!
My pleasure, happy Umbracoing!! :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Show lastest three posts
Hi guys :-)
I'm trying to output my blogposts from a partial view to frontpage. However i only want to show the lastest three posts.
It seems like it should be very easy, however I cant seem to figure it out. Maybe you can help me?
Heres my partial view code:
@{ var selection = Model.Content.Site().FirstChild("portfolio").Children() .Where(x => x.IsVisible()) .OrderBy("CreateDate desc"); }
Please tell if my question is unclear to you.
Best regards Lasse
Hi Lasse
What about this, off the top of my head this may help, or at least point you in the right direction
Notice the addition of .Take(3)
WUHUUU L1ca! It works like a dream! :-) Thank you so much!
My pleasure, happy Umbracoing!! :)
is working on a reply...