diff --git a/templates/kt3/document_collection.smarty b/templates/kt3/document_collection.smarty index 28190a2..5dac157 100644 --- a/templates/kt3/document_collection.smarty +++ b/templates/kt3/document_collection.smarty @@ -42,6 +42,7 @@ {i18n arg_itemCount=$context->itemCount arg_batchSize=$context->batchSize}#itemCount# items, #batchSize# per page{/i18n} + {if ($pagecount > 1)} {if ($currentpage == 0)} « prev @@ -54,15 +55,48 @@ {else} next » {/if} - {foreach item=showPage from=1|range:$pagecount} - · - {if ($showPage-1 != $currentpage)} - {$showPage} + {assign var=shownEllipsis value=false} + {foreach item=showPage from=1|range:$pagecount name=pagecrumbs} + {assign var=showCrumb value=false} + {capture assign=relative}{$showPage-1-$currentpage}{/capture} + {if $smarty.foreach.pagecrumbs.total <= 27} + {assign var=showCrumb value=true} + {elseif $showPage <= 5} + {assign var=showCrumb value=true} + {elseif abs($relative) <= 5} + {assign var=showCrumb value=true} + {elseif $relative > 0 and $relative <= 10} + {assign var=showCrumb value=true} + {elseif abs($smarty.foreach.pagecrumbs.total - ($showPage - 1)) <= 3 } + {assign var=showCrumb value=true} + {elseif $currentpage < 13 && $showPage <= 23} +{*ie, show up to 23 always, 13 = 23 - 10 (forward)*} + {assign var=showCrumb value=true} + {elseif ($smarty.foreach.pagecrumbs.total - $currentpage) < 16 && ($smarty.foreach.pagecrumbs.total - $showPage) < 20} +{*ie, always show back 20 if we're in the last 20, +(not 23, since we show 5 from the front if not in the front 23 or so, +and only 3 from the back if we're not in the back 20 or so. 20 - 16 = 5 +(according to my math)*} + {assign var=showCrumb value=true} + {/if} + + {if $showCrumb} + · + {if ($showPage-1 != $currentpage)} + {$showPage} + {else} + {$showPage} + {/if} + {assign var=shownEllipsis value=false} {else} - {$showPage} + {if not $shownEllipsis} + · … + {assign var=shownEllipsis value=true} + {/if} {/if} {/foreach} {/if} +