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.

Showcase Questions /

Feedback and questions about sites in the Community Showcase.

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

Custom PaginationList


Go to End
Reply


2 Posts   1336 Views

Avatar
purzel

Community Member, 1 Post

31 October 2015 at 9:49am

Hello,

i use the PaginationList from Lesson 15 for a DataList "ArtikelObject". Everythink works fine, but my PaginationList show me now all 226 Pages in the Pager. I would have something like this:
<< 1 .... 6 7 8(Current) 9 10 .... 226 >>
2 Links before Current und 2 Links after Current.
Can I prepare the Links in php or it is possible make this in Template?
My Php Function:
public function getArtikel(SS_HTTPRequest $request) {
$start= 0;
if (isset($_GET['start'])) {
$start = $_GET['start'];
}
$request = array();
$list = ArtikelObject::get()->filter(array('ArticleHolderID' => $this->ID, 'Zustand' => '2'));
$pages = new PaginatedList($list, $request);
$pages->setPageLength(10)->setPageStart($start);
return $pages;
}
Please help,
Greatings Barbara

Avatar
Kirk

Community Member, 67 Posts

4 February 2016 at 4:52pm

Try the following link for more info https://docs.silverstripe.org/en/3.2/developer_guides/templates/how_tos/pagination/
It has a good example which shows how to control the Pagination controls

<% if $PaginatedPages.MoreThanOnePage %>
    <% if $PaginatedPages.NotFirstPage %>
        <a class="prev" href="$PaginatedPages.PrevLink">Prev</a>
    <% end_if %>
    <% loop $PaginatedPages.Pages %>
        <% if $CurrentBool %>
            $PageNum
        <% else %>
            <% if $Link %>
                <a href="$Link">$PageNum</a>
            <% else %>
                ...
            <% end_if %>
        <% end_if %>
        <% end_loop %>
    <% if $PaginatedPages.NotLastPage %>
        <a class="next" href="$PaginatedPages.NextLink">Next</a>
    <% end_if %>
<% end_if %>