« All helpers
Generates a reusable pager for lists of data.
Usage:
$limit = 20; $num = isset ($this->params[0]) ? $this->params[0] // from the URL, e.g. /myapp/handler/# : 1; $offset = ($num - 1) * $limit; $items = MyModel::query ()->fetch ($limit, $offset); $total = MyModel::query ()->count (); $data = array ( 'limit' => $limit, 'total' => $total, 'items' => $items, 'count' => count ($items), 'single' => __ ('page'), 'plural' => __ ('pages'), 'url' => '/myapp/handler/%d' ); echo $tpl->render ('myapp/view', $data);
Text pager:
{! navigation/pager ?style=text &url=[url] &total=[total] &count=[count] &limit=[limit] !}
Will show:
<< Newer results Older results >>
Text pager with a custom label:
{! navigation/pager ?style=text &url=[url] &total=[total] &count=[count] &limit=[limit] &label=pages !}
<< Newer pages Older pages >>
Numeric pager:
{! navigation/pager ?style=numbers &url=[url] &total=[total] &count=[count] &limit=[limit] !}
<< 1 2 3 4 >>
Numeric pager with extra links:
{! navigation/pager ?style=numbers &url=[url] &total=[total] &count=[count] &limit=[limit] &extra[all]=All pages &extra[/search]=Search !}
<< 1 2 3 4 >> All pages Search
'All pages' will link to '/myapp/handler/all' based on the 'url' value in the PHP code above, while 'Search' will link to '/search', an external link.
Standard "X to Y of Z results" pager with a custom label:
{! navigation/pager ?style=results &url=[url] &total=[total] &count=[count] &limit=[limit] &single=page &plural=pages !}
1 to 20 of 32 pages:
Short-form pager:
{! navigation/pager ?style=short &url=[url] &total=[total] &count=[count] &limit=[limit] !}
1-20 of 32:
All elements can be styled with CSS classes.
Generates a reusable pager for lists of data.
Usage:
1. Set your data as follows:
2. In your template
Text pager:
Will show:
Text pager with a custom label:
Will show:
Numeric pager:
Will show:
Numeric pager with extra links:
Will show:
'All pages' will link to '/myapp/handler/all' based on the 'url' value in the PHP code above, while 'Search' will link to '/search', an external link.
Standard "X to Y of Z results" pager with a custom label:
Will show:
Short-form pager:
Will show:
All elements can be styled with CSS classes.