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.

Template Questions

paginatedList with offset


Reply

161 Views

Avatar
Phils

11 June 2014 at 6:04am (Last edited: 11 June 2014 6:06am), Community Member, 10 Posts

Hi everybody,

I'm trying to do a News Archive Page. I want to get all News after offset 10 to show in a paginatedList. The first 10 News will show on the News Page.

So I tried:

public function getNewsArchiveList() {
   $NewsList = News::get()->limit(0,10);
   $paginatedList = new PaginatedList($NewsList, $this->request);
   $paginatedList->setPageLength(2);
   return $paginatedList;
}

That didn't work.

Then I tried:

public function getNewsArchiveList() {
   $NewsList = News::get();
   $paginatedList = new PaginatedList($NewsList, $this->request);
   $paginatedList->setPageLength(2);
$paginatedList->setPageStart(10);
   return $paginatedList;
}

That only worked on page 1 of the PaginatedList. The other pages didn't switch the news. They all showed the same news than page 1.

In my .ss Template I got:

<% loop NewsArchiveList %>
$Title
<% end_loop %>

<% if $NewsArchiveList .MoreThanOnePage %>
<% if $NewsArchiveList.NotFirstPage %>
   <a href="$NewsArchiveList .FirstLink">first</a>
<a href="$NewsArchiveList .PrevLink">prev</a>
<% end_if %>
<% if $NewsArchiveList.NotLastPage %>
<a href="$NewsArchiveList .NextLink">next</a>
<a href="$NewsArchiveList .LastLink">last</a>
<% end_if %>
<% end_if %>

Anybody got that to work before? I would very much appreciate every hint.

Thanks,
Philip