Jump to:

3435 Posts in 1026 Topics by 866 members

Template Questions

SilverStripe Forums » Template Questions » paginatedList with offset

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

Page: 1
Go to End
Author Topic: 95 Views
  • Phils
    Avatar
    Community Member
    9 Posts

    paginatedList with offset Link to this post

    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

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