I have one page in my website where i need to list all blogs entere from Umbraco CMS.
There may have hundreds of blogs entere in Umbraco CMS and i need to display it on my front end web site. I know how to iterate through all the blogs on cshtml page and how to display. Right now all the blogs are appear on same page.
What i need is i need to display 20 blogs on each pages and need to show paging at bottom.
you could retrieve the correct set of blog posts to return if you wanted to display 10 on each...
@{
// Get all blog posts
var posts = Model.Content.Children.Where(c => c.DocumentTypeAlias.Equals("blogPost"));
// Find the current page number if we have one
var page = 1;
if (Request["page"] != null)
{
if (!int.TryParse(Request["page"], out page))
{
// Default to the first if we don't
page = 1;
}
}
// Skip all posts before the current page
// and take the next 10
var postsToDisplay = posts.Skip(10 * (page - 1)).Take(10);
foreach (var post in postsToDisplay)
{
// Display blog post
}
}
how to achieve paging in umbraco "cshtml" page?
Hi
I have one page in my website where i need to list all blogs entere from Umbraco CMS.
There may have hundreds of blogs entere in Umbraco CMS and i need to display it on my front end web site. I know how to iterate through all the blogs on cshtml page and how to display. Right now all the blogs are appear on same page.
What i need is i need to display 20 blogs on each pages and need to show paging at bottom.
So how to achieve this ?
Can anyone please help me here ?
Thanks in advance !
Rohan Dave
Hi Rohan,
You could pass a page number as a query string parameter to determine which set of blog posts to display. For example, with the below url...
you could retrieve the correct set of blog posts to return if you wanted to display 10 on each...
Thanks, Dan.
is working on a reply...