Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Counting Page to create Pagination

Go to End

3 Posts   1761 Views


Community Member, 20 Posts

9 July 2008 at 4:13am

Is there a pagination system for the site content pages? I would like to calculate the number of submenu pages and have it generate the next and previous buttons. For example: My main menu section is titled ABOUT. Under the ABOUT section there are 12 pages... at the bottom of the first page I would like it to read

1 of 12 [next]

when you are on page 2 it will read

[prev] 2 of 12 [next]

and when you are on the last page it will read

[prev] 12 of 12

I would like this pagination system for each of the "main" sections I set up.

Is there something like this available? if not does anyone know how I can create it? I'm pretty new to SilverStripe and am trying to figure it all out.

I will need to...

#1 calculate the number of submenus/pages under a main menu (how many Child pages are assigned to this (current) Parent page?)

#2 the current Child page that I am on is number ? (1-12) in the list (database) of Child pages for that Parent page.

I hope I'm explaining this well... its a bit confusing but I think figuring out these two things will then generate what I am looking for.



Community Member, 712 Posts

9 July 2008 at 11:20am

This may or may not help, but the following variables are available within the page class:

$Pos (current iterator position) and $TotalItems (total items). They're inherited from the site tree so I think they should give you info about the current page position and sibling tiems.


Community Member, 20 Posts

11 July 2008 at 1:21pm

in what files do I add in this code? would it be the under the Layout directory?