Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
SilverStripe PaginatedPages show custom summary

I am have trouble using the PaginatedPages. In the docs, it's possible to customize the summary.

There is my code :

public function PaginatedPages($n = 10) {
    $list = Page::get()->sort(array('Date' => DESC));
    $Pages = new PaginatedList($list, $this->request);
    if ($_GET['results'] != "") {
        $n = $_GET['results'];
    }
    $Pages->setPageLength($n);
    return $Pages;
}

The pagination in the bottom of the template page :

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

This code reproduces:

[1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20]

I don't want this. If a have 20 pages of results, it will show all and the result is to long and ugly.

I want the following:

[1] ... [9] [10] [11] [12] [13] ... [20]
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can use $PaginatedPages.PaginationSummary to achieve this:

<div id="PaginatedPages">
    <% if $PaginatedPages.MoreThanOnePage %>
        <% if $PaginatedPages.NotFirstPage %>
            <a class="prev" href="$PaginatedPages.PrevLink"><</a>
        <% end_if %>
        <% loop $PaginatedPages.PaginationSummary %>
            <% if $CurrentBool %>
                <a class="current">$PageNum</a>
            <% else %>
                <% if $Link %>
                    <a href="$Link">$PageNum</a>
                <% else %>
                    ...
                <% end_if %>
            <% end_if %>
            <% end_loop %>
        <% if $PaginatedPages.NotLastPage %>
            <a class="next" href="$PaginatedPages.NextLink">></a>
        <% end_if %>
    <% end_if %>
</div>

PaginationSummary returns a summarised pagination which limits the number of pages shown around the current page for visually balanced. It

PaginationSummary can take a parameter to control the number of pages to display around the current page. By default PaginationSummary will show 4 pages around the current page (2 pages before, 2 pages after. eg [1] ... [4] [5] [[6]] [7] [8] ... [25]). Calling PaginationSummary(6) would result in 3 pages before and 3 pages after the current page. eg [1] ... [3] [4] [5] [[6]] [7] [8] [9] ... [25]. The number should always be even, as half the number of each pages are displayed on either side of the current one.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda