Ideally you should wait converting the collection to a list until you're done manipulating your collection - eg. after you have applied pagination. Otherwise you may end up converting to a list multiple times.
var selection = Umbraco.TypedContent(1999).Children("mOPNewsPost").Where(x => x.IsVisible()).OrderBy("CreateDate");
var numberOfPosts = Model.Content.GetPropertyValue<int>("newsItems");
var newsposts = selection.OrderByDescending(x => x.CreateDate).Where(x => x.NewType2 == @PageTheme).ToList();
var pageCount = (int)Math.Ceiling((double)newsposts.Count / (double)numberOfPosts);
var page = 1;
if (!string.IsNullOrEmpty(Request.QueryString["page"]))
{
int.TryParse(Request.QueryString["page"], out page);
if (page <= 0 || page > pageCount)
{
page = 1;
}
}
//Gets the blogposts for the current page
var pagedNewsposts = newsposts.Skip((page - 1) * numberOfPosts).Take(numberOfPosts).ToList();
}
@foreach(var item in pagedNewsposts){
var PageType = item.GetPropertyValue
ToList help
Hi,
I am trying to create a list
I am trying to only pull certain content out. Currently using an if statement further down the page but this breaks pagniation
Is there was I can exclude the content?
Thanks
Hi Michael,
Can you perhaps share a bit more of your code?
Ideally you should wait converting the collection to a list until you're done manipulating your collection - eg. after you have applied pagination. Otherwise you may end up converting to a list multiple times.
string PageTheme = Model.Content.GetPropertyValue
}
@foreach(var item in pagedNewsposts){ var PageType = item.GetPropertyValue
is working on a reply...