Jevon Boyce

Jevon Boyce

Был в сети 03 января 2020, 20:43
Заказы не принимаю
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;
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?