We'll assume our fictional company, Widgets Ltd, writes about ten articles a month and want the articles page to act like a blog
That wouldn't take long before there are way too many articles for one page, but the tutorial does not go into how to add pagination, and any articles I can find online tend to be either for earlier versions (that I can't get working), or way beyond my current abilities.
Could somebody point me in the right direction? Thanks.
The most straight forward method for pagination would be to make use of the LINQ Skip & Take options, where Take is the amount of items you want on your page, and the Skip is the ((Pagenumber * Take) - Take).
An example of pages with 10 items on them, where we want to fetch items for Page 3:
Personally I would implement it the same way as you have described, using query strings, with the addition to leave ?Show=1 blank when entering the page for the first time, where 1 would be the default page, and then have it be something like ?page=2 or ?p=2..n for any following pages!
Pagination when listing parent / child content
Hi. I have been working through the official documentation tutorials and followed the below to create a Parent / Item setup:
https://our.umbraco.com/documentation/Tutorials/Creating-Basic-Site/Articles-Parent-and-Article-Items/
On that page, they say
That wouldn't take long before there are way too many articles for one page, but the tutorial does not go into how to add pagination, and any articles I can find online tend to be either for earlier versions (that I can't get working), or way beyond my current abilities.
Could somebody point me in the right direction? Thanks.
Hi Steve,
The most straight forward method for pagination would be to make use of the LINQ Skip & Take options, where Take is the amount of items you want on your page, and the Skip is the ((Pagenumber * Take) - Take).
An example of pages with 10 items on them, where we want to fetch items for Page 3:
Which in this case would return you the 10 items you would display on Page 3 (Items 21-30).
Hope this helps!
Kind regards,
Corné Hoskam
Thanks for the reply Corné. I will look into this further.
When building the pagination buttons, would querystrings be best?
So... thinking this through, if we were on page 3 of 6 we'd have something like the below:
with the following hyperlinks
Obviously with a little logic to build this navigation automatically and disable buttons where not needed etc.
Or is there a better way?
Hi Steve,
Personally I would implement it the same way as you have described, using query strings, with the addition to leave ?Show=1 blank when entering the page for the first time, where 1 would be the default page, and then have it be something like ?page=2 or ?p=2..n for any following pages!
Kind regards,
Corné
is working on a reply...