Pagination Pre 1.3.0
From Adult Web Scripts Wiki
This code will still work with zestoi >= 1.3.0 but the new method is simpler and includes query args - see here Pagination
A standard url config entry that allows for pagination will have %page% at the end like /blog/%page% making /blog/ and /blog/1 page 1 and /blog/2 page 2 etc...
The following code examples do these things:
- decodes the current URL and extracts the urlconfig_name
- extracts the current max_pages
- loops round creating links by encoding the extracted url config item
PHP
<? $url = zestoi_decode_url(); $num_pages = zestoi_val('num_pages'); for ($pageloop=1; $pageloop<$num_pages; $pageloop++): ?> <a href="<?= zestoi_url_encode($url['urlconfig_name'], array('page' => $pageloop)) ?>"><?= $pageloop ?></a> <? endfor; ?>
Smarty
{* decode the current page url *} {decode_url var=url} {* grab the current page number *} {val name=num_pages var=maxpage} {* loop round each page and create a link *} {section name=pageloop start=1 loop=$maxpage} <a href="{url_encode urlconfig_name=$url.urlconfig_name _args=$url.args page=$smarty.section.pageloop.index}">{$smarty.section.pageloop.index}</a> {/section}
