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.

Data Model Questions /

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

[Solved] Having a problem with Pagination on Silverstripe 3

Go to End

3 Posts   1580 Views


Community Member, 136 Posts

13 September 2013 at 12:44am

Hi, I'm using PaginatedList on one of my functions, and it's working fine - limiting the display of the results - but when I try to view the "NextLink" it just displays the same list again (starting with the first result). The URL changes eg. ?start=12 is added but the results don't change.

Am I missing something?

My Function (working):

public function PaginatedWork() {
$paginatedList = new PaginatedList(DataObject::get("WorkPage", "", "", "", ""));
return $paginatedList;

On the template <% loop $PaginatedWork %> is working (showing just the first 12 results)

But the link to view the next Page isn't working:

<% if $PaginatedWork.NotLastPage %><a class="next" href="$PaginatedWork.NextLink">&gt;</a><% end_if %>

URL updates with ?start=12 but the items displayed don't change

Any ideas??


Community Member, 17 Posts

13 September 2013 at 2:56am

I'm not familiar with the new PaginatedList approach - I've only done it the old way but from looking through the docs it looks like you may need to add $this->request as the second argument....

$paginatedList = new PaginatedList(DataObject::get("WorkPage", "", "", "", ""), $this->request);

It would need to know which page your are on based on the start parameter (?start=12 ?start=24 etc) - otherwise it's just getting everything from the first db record.

Hope that helps/works!


Community Member, 136 Posts

13 September 2013 at 3:05am

Perfect! That works, thank you!