Jump to:

3432 Posts in 1025 Topics by 865 members

Template Questions

SilverStripe Forums » Template Questions » Can't Get Pagination to Work

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

Page: 1
Go to End
Author Topic: 332 Views
  • PattyOK
    Avatar
    Community Member
    5 Posts

    Can't Get Pagination to Work Link to this post

    Hello - I attempted to follow this tutorial on pagination. http://doc.silverstripe.org/framework/en/howto/pagination

    I cant make it work the way I want. I dont know if I am doing something wrong or if I am misinterpreting how its supposed to be used...

    This is in my page controller - I am limiting this to "Projects".

    public function PaginatedProjects() {
    $pagination = new PaginatedList(Page::get('Project'), $this->request);
    return $pagination;
    }

    In my Project page template this works to return a list of projects

    <% loop $PaginatedProjects %>
             <li><a href="$Link">$Title</a></li>
          <% end_loop %>

    but none of the other methods seem to work.
    TotalItems always returns 1
    PrevLink, NextLink return blank

    I really just want Prev, Next links. Is there a working example of pagination out there or a prev/next example that works with SS3?

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Can't Get Pagination to Work Link to this post

    That seems correct, do you get a list of all your Projects at least? The example on http://doc.silverstripe.org/framework/en/howto/pagination does also work as reference.

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: Can't Get Pagination to Work Link to this post

    I suspect that "Page::get('Project')" should probably be Project::get()

  • PattyOK
    Avatar
    Community Member
    5 Posts

    Re: Can't Get Pagination to Work Link to this post

    Ack. I grossly misinterpreted what this was going to do for me . Setting the page length to less than the number of pages, I finally got the controls to show up and now I see what they do... (duh). If the tutorial page had a working example that actually demonstrates the functionality that might have helped me come to that sooner... Anyways thanks for your responses.

  • thomas.paulson
    Avatar
    Community Member
    67 Posts

    Re: Can't Get Pagination to Work Link to this post

    try this

    public function PaginatedProjects() {
    $pagination = new PaginatedList(Project::get(), $this->request);
    return $pagination;
    }

    332 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.