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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Change Pagination number


Reply

3 Posts   181 Views

Avatar
Bagzli

30 January 2014 at 4:19pm Community Member, 37 Posts

Hey guys,

I've tried following this tutorial to get pagination working: http://doc.silverstripe.com/framework/en/howto/pagination

I've managed to get it to work and it defaults to 10 results per page, however I cannot figure out how to change that number and set it to 3 or 5 or whatever I need. I'm not sure what the code is nor where I would put it.

Anyone can help?

Avatar
martimiz

2 February 2014 at 2:54am Forum Moderator, 1091 Posts

This should work:

   public function PaginatedPages() {
      return PaginatedList::create(Page::get(), $this->request)->setPageLength(3);
   }

Avatar
Bagzli

3 February 2014 at 4:07am (Last edited: 3 February 2014 4:37am), Community Member, 37 Posts

Thank you, worked like a charm.