Many many thanks for this. It's helped me hugely. Noticed a couple of minor issues that stopped it working properly so have added them in bold below.
@inheritsUmbracoTemplatePage @{Layout="MasterTemplate.cshtml";} @{ var pageSize =3; var page =1;int.TryParse(Request.QueryString["page"],out page); var items =Model.Content.Children().Where(x => x.IsDocumentType("BlogPost")).OrderByDescending(x => x.CreateDate); var totalPages =(int)Math.Ceiling((double)items.Count()/(double)pageSize);
if you are having as much fun as I did with some of the codes above (Craig100's) or the one before that (Lee Kelleher) double-check that the html tags are closed correctly. The code works great after modifying for what I need it to do, but don't copy and paste it verbatim, close your html tags first
Razor Paging snippet
Hi,
I want to add paging navigation to a page. Does anyone know where I can find a good snippet of Paging using Razor ?
Thanks for your help,
Anthony
Hi!
Url-based paging? What about http://cultiv.nl/blog/2011/2/17/how-to-use-razor-in-umbraco-paging/ or do you like a javascripted version?
I used this blog post as a reference the other day.
http://www.diplo.co.uk/blog/2011/6/21/creating-a-paged-list-in-umbraco-using-razor.aspx
It's using the "old" style Razor, but I tweaked it for v6 MVC style.
Hi Lee, Jonas,
Thanks for the advice. I implemented Dan Diplo's solution, and it works fine!
greetings,
Anthony
Hi,
Try this example also:
http://umbraco.com/help-and-support/video-tutorials/umbraco-fundamentals/razor-recipes/news.aspx
Hi Lee,
I'm using MVC V6.1.1 and need to implement paging. However, I don't know how to "V6" Dan Diplo's solution. Could you share?
Tried looking at Warren's UmbTVcast on the subject but again it's for V4 so some of the stuff like .InGroupsOf(x) doesn't work (or I can't find it).
Cheers,
Craig
Hi Craig,
Here's a stripped-down version of the code I used:
Hope it helps?
Cheers, Lee.
Hi Lee,
Many many thanks for this. It's helped me hugely. Noticed a couple of minor issues that stopped it working properly so have added them in bold below.
Thanks again.
Cheers,
Craig
Hi all.
Possible to paging in server side.
Has anyone ever adapted this to a more advanced pagination system for a ton of nodes where the pagination "hides" nodes too far from the current one?
Like 1 2 3 ...56 57 58
-Amir
Hi Amir,
You would do something along the lines of the following:
This will display the first and last pages as well as a page either side of the current page. I hope this helps.
Hi All,
I am using the suggested pagination razor code snippet, as re-listed by Lee.
I want to include in the pagination such as showing: "Viewing 1 - 5 of 30 News" , "Viewing 6 - 10 of 30 News" for example.
Can someone help me.
Thank you.
Kind Regards
For Foundation Zurb 5
It works nice and smooth. Thank you :)
if you are having as much fun as I did with some of the codes above (Craig100's) or the one before that (Lee Kelleher) double-check that the html tags are closed correctly. The code works great after modifying for what I need it to do, but don't copy and paste it verbatim, close your html tags first
Thanks for all the help I found here!
I'm having trouble converting this if/else into a ternary and was wondering if anyone had any tips? I can't manage to escape the HTML properly.
Working:
Not working (& every variation I've tried):
Renders (or something similar):
Full pagination logic below
I'm displaying a limited range of pages that centers the current page:
Thanks for any advice!
is working on a reply...