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
Consider the following code:
@{
var pageSize = 9;
var page = 1; int.TryParse(Request.QueryString["page"], out page);
var items = Umbraco.TypedContent(Model.Content.Id).Children.Where(x => x.DocumentTypeAlias == "PortfolioItem" && x.IsVisible());
var totalPages = (int)Math.Ceiling((double)items.Count() / (double)pageSize);
if (page > totalPages)
{
page = totalPages;
}
else if (page < 1)
page = 1;
SECOND PART OF THE CODE
@foreach (var item in items.Skip((page - 1) * pageSize).Take(pageSize).OrderBy(x => x.Name))
@(Umbraco.Truncate(item.GetPropertyValue("PortfolioItemBodyText").ToString(), 100, false))
Read More
In the second section of the code i need to be able to encapsulate 3 of the items generated in the foreach with a
Hi James,
Could you try to repost with the markdown editor and mark the code sections with the "code sample" button so that we can hopefully see it all?
Jeavon
Here is James' code:
@{ var pageSize = 9; var page = 1; int.TryParse(Request.QueryString["page"], out page); var items = Umbraco.TypedContent(Model.Content.Id).Children.Where(x => x.DocumentTypeAlias == "PortfolioItem" && x.IsVisible()); var totalPages = (int)Math.Ceiling((double)items.Count() / (double)pageSize); if (page > totalPages) { page = totalPages; } else if (page < 1) { page = 1; } }
And the second part:
@foreach (var item in items.Skip((page - 1) * pageSize).Take(pageSize).OrderBy(x => x.Name)) { @item.GetPropertyValue("PortfolioItemTitle") @item.Name @(Umbraco.Truncate(item.GetPropertyValue("PortfolioItemBodyText").ToString(), 100, false)) Read More }
Cool, and what did you want to encapsulate it with?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
A foreach problem
Consider the following code:
@{
var pageSize = 9;
var page = 1; int.TryParse(Request.QueryString["page"], out page);
var items = Umbraco.TypedContent(Model.Content.Id).Children.Where(x => x.DocumentTypeAlias == "PortfolioItem" && x.IsVisible());
var totalPages = (int)Math.Ceiling((double)items.Count() / (double)pageSize);
if (page > totalPages)
{
page = totalPages;
}
else if (page < 1)
{
page = 1;
}
}
SECOND PART OF THE CODE
@foreach (var item in items.Skip((page - 1) * pageSize).Take(pageSize).OrderBy(x => x.Name))
{
@item.GetPropertyValue("PortfolioItemTitle")
@item.Name
@(Umbraco.Truncate(item.GetPropertyValue("PortfolioItemBodyText").ToString(), 100, false))
Read More
}
In the second section of the code i need to be able to encapsulate 3 of the items generated in the foreach with a
Hi James,
Could you try to repost with the markdown editor and mark the code sections with the "code sample" button so that we can hopefully see it all?
Jeavon
Here is James' code:
And the second part:
Cool, and what did you want to encapsulate it with?
is working on a reply...