I've been working on code for a "real" pagination, i.e. not only links to the next and previous pages, but to the next and previous three pages of a blog. Other objectives I gave myself: I wanted to do this using only Smarty (which according to http://board.s9y.org/viewtopic.php?t=1794 is possible - and indeed it is), plus I also wanted to display seven links even if there are no three previous or next pages (i.e. show pages 1-7 if the current page is between 1 and 7 etc.).
So this is the code I came up with:
Code: Select all
<div class="pagelinks">
{eval var=$footer_currentPage-3 assign="paginationStartPage"}
{eval var=$footer_currentPage+3 assign="paginationEndPage"}
{if $paginationStartPage <= 0}{assign var="paginationStartPage" value="1"}{/if}
{if $paginationEndPage <= 7}{assign var="paginationEndPage" value="7"}{/if}
{if $paginationEndPage >= $footer_totalPages+1}
{eval var=$footer_totalPages-6 assign="paginationStartPage"}
{eval var=$footer_totalPages assign="paginationEndPage"}
{/if}
{section name=i loop=$footer_totalPages+1}
{if $smarty.section.i.index >= $paginationStartPage and $smarty.section.i.index <= $paginationEndPage}
{if $smarty.section.i.index != $footer_currentPage}<a href="{$footer_pageLink|@sprintf:$smarty.section.i.index}">{/if}{$smarty.section.i.index}{if $smarty.section.i.index != $footer_currentPage}</a>{/if}
{/if}
{/section}
</div>
YL