Quote from: mk99 at Apr 02, 2009, 08:54 PM
i’m using splitpagination, but it’s not working on cashed page too, What particular Ditto region i need to call, can you be more specific?
Here’s fixed SplitPagination, call it on cached page with PHx, immediately after your
Ditto id=`a` call:
[!DittoPageSplit? &id=`a` &output=`1`!]
Change templating inside last (if $output) block:
<?php //only for forum highlighting
// Place immediately following a Ditto call
// Based on the function written by Aaron Hall, evilwalrus.org
// Ditto 2.1 start page fix & PHx workaround: Eol ([email protected])
if (!function_exists("generatePagination")) {
function generatePagination($curPage, $totResults, $resultsPerPage) {
$totPages = ceil($totResults / $resultsPerPage);
$pagesBefore = $curPage - 1;
$pagesAfter = $totPages - $curPage;
$tabArr = array();
if ($totPages > 15) {
if ($pagesBefore > 7) {
$tabArr = array(1, 2, 0);
if ($pagesAfter > 7) {
for ($i=($curPage-4); $i<$curPage; $i++) { $tabArr[] = $i; }
} else {
for ($i=($totPages-11); $i<$curPage; $i++) { $tabArr[] = $i; }
}
} else {
for ($i=1; $i<$curPage; $i++) { $tabArr[] = $i; }
}
$tabArr[] = $curPage;
if ($pagesAfter > 7) {
if ($pagesBefore > 7) {
for ($i=($curPage+1); $i<=$curPage+4; $i++) { $tabArr[] = $i; }
} else {
for ($i=($curPage+1); $i<13; $i++) { $tabArr[] = $i; }
}
$tabArr[] = 0;
$tabArr[] = $totPages-1;
$tabArr[] = $totPages;
} else {
for ($i=($curPage+1); $i<=$totPages; $i++) { $tabArr[] = $i; }
}
} else {
for ($i=1; $i<=$totPages; $i++) { $tabArr[] = $i; }
}
return $tabArr;
}//function generatePagination end
}
$id = isset($id) ? $id.'_' : '';
$total = isset($total) ? $total : $modx->getPlaceholder($id."total");
$start = isset($start) ? $start : $modx->getPlaceholder($id."urlStart");
$summarize = isset($summarize) ? $summarize : $modx->getPlaceholder($id."perPage");
$currentPage = isset($currentPage) ? $currentPage : $modx->getPlaceholder($id."current");
$landing = isset($tagDocumentID) ? $tagDocumentID : $modx->documentObject['id'];
if ($total == 0 || $summarize == 0) {
return false;
}
$page = ($start/$summarize)+1;
$output = isset($output) ? $output : 0;
$paginationArray = generatePagination($page, $total, $summarize);
$ph = "";
$cInc = $_GET[$id.'start'];
foreach ($paginationArray as $page) {
$inc = ($page-1) * $summarize;
if ($page == 0) {
$ph .= "..."; // represents pages that aren't displayed
} else if ($inc == $cInc) {
$ph .= "<span class=\"active\">{$page}</span>";
} else {
$ph .= "<a class=\"page\" href=\"".ditto::buildURL("start=".$inc, $landing, $id)."\">{$page}</a>\n";
}
}
$modx->setPlaceholder("{$id}pagesplit", $ph);
if ($output) { return "
<div class=\"pages\">
<strong>[+{$id}start+]</strong>-<strong>[+{$id}stop+]</strong> od <strong>[+{$id}total+]</strong>
[+{$id}previous+] {$ph} [+{$id}next+]
</div>";
}
See it working here:
http://www.burzanautike.com/testovi?a_start=10