Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Counting Page to create Pagination

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

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

Page: 1
Go to End
Author Topic: 1347 Views
  • cindycin
    Avatar
    Community Member
    20 Posts

    Counting Page to create Pagination Link to this post

    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.

    Thanks.

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: Counting Page to create Pagination Link to this post

    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.

  • cindycin
    Avatar
    Community Member
    20 Posts

    Re: Counting Page to create Pagination Link to this post

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

    1347 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.