Using pdoPage pagination placeholders

Hello,

Is it possible to show «Showing 1 to 5 of 15 (3 Pages)», «Showing 6 to 10 of 15 (3 Pages)», «Showing 11 to 15 of 15 (3 Pages)»,...etc with pdoPage? is there a placeholder for firstItem and lastitem? I have been searching online but I cannot find any solution to my question.
Jevon Boyce
26 мая 2019, 01:13
modx.pro
735
0

Комментарии: 4

Василий Наумкин
26 мая 2019, 07:20
0
You could just wrap your call with another snippet:
[[!pdoPageWrapper?
    &parents=`0`
    &limit=`5`
]]
[[!+page.nav]]

pdoPageWrapper:
<?php

$output = $modx->runSnippet('pdoPage', $scriptProperties);

$total = $modx->getPlaceholder('page.total');
$pages = $modx->getPlaceholder('pageCount');
$page = $modx->getPlaceholder('page');

$from = (($page - 1) * $limit) + 1;
$to = (($page - 1) * $limit) + $limit;
if ($to > $total) {
    $to = $total;
}

return $output . "<p>Showing $from to $to of $total ($pages pages)</p>";
    Jevon Boyce
    28 мая 2019, 19:18
    0
    Thank you, this works.

    I'm using the pdoPageWrapper with the mFilter2 snippet. I have created to placeholders with the snippet that you wrote.
    <?php
    
    $snippet = $modx->getOption('snippet', $scriptProperties, 'pdoPage');
    $output = $modx->runSnippet($snippet, $scriptProperties);
    
    $total = $modx->getPlaceholder('page.total');
    $pages = $modx->getPlaceholder('pageCount');
    $page = $modx->getPlaceholder('page');
    
    $from = (($page - 1) * $limit) + 1;
    $to = (($page - 1) * $limit) + $limit;
    if ($to > $total) {
        $to = $total;
    }
    
    $modx->setPlaceholder('page.from',$from);
    $modx->setPlaceholder('page.to',$to);
    
    return $output;
    But now the placeholders doesn't work with the ajax mode. How can I get this to work with mFilter2 Ajax mode?
      Василий Наумкин
      28 мая 2019, 22:15
      0
      mFilter2 have special option &paginator.

      So
      [[!mFilter2?
          &paginator=`pdoPageWrapper`
          &...
      ]]

      How can I get this to work with mFilter2 Ajax mode?
      Please, send all questions about paid extras to the modstore.pro support.
    Jevon Boyce
    03 июня 2019, 22:38
    0
    I'm sorry but I'm not getting the Ajax pagination to work. Can you explain to me where I'm going wrong?
    [[!mFilter2?
        &parents=`[[*id]]`
        &paginator=`pdoPageWrapper@pagepagination`
        &element=`msProducts`
        &class=`msProduct`
        &sortold=`ms|price:desc`
        &sort=`resource|menuindex:asc`
        &limit=`3`
        &tplOuter=`nd.tpl.mFilter2.outer`
        &tpl=`nd.tpl.msProducts.row`
        &tplFirst=`nd.Firsttpl.msProducts.row` 
        &tpl_n3=`nd.Thirdtpl.msProducts.row` 
        &tplLast=`nd.Lasttpl.msProducts.row`
        &includeThumbs=`246x246`
    ]]
    Snippet
    <?php
    $snippet = $modx->getOption('snippet', $scriptProperties, 'pdoPage');
    $output = $modx->runSnippet($snippet, $scriptProperties);
    
    $total = $modx->getPlaceholder('page.total');
    $pages = $modx->getPlaceholder('pageCount');
    $page = $modx->getPlaceholder('page');
    
    $from = (($page - 1) * $limit) + 1;
    $to = (($page - 1) * $limit) + $limit;
    if ($to > $total) {
        $to = $total;
    }
    
    $modx->setPlaceholder('page.from',$from);
    $modx->setPlaceholder('page.to',$to);
    
    return $output;
      Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
      4