Skip to content

Instantly share code, notes, and snippets.

@blackreaven
blackreaven / Pager.twig
Created October 3, 2013 15:52
Twig pager
{#
# count => total item
# limit => item by page
# offset => start item idex
# page => current page
# lastpage => last page = page number
# adjacents => page count display before and after the current page
#}
{% if limit is not defined %}
{% set limit = 10 %}
//function to return the pagination string
function getPaginationString($page = 1, $totalitems, $limit = 15, $adjacents = 1, $targetpage = "/", $pagestring = "?page=")
{
//defaults
if(!$adjacents) $adjacents = 1;
if(!$limit) $limit = 15;
if(!$page) $page = 1;
if(!$targetpage) $targetpage = "/";
//other vars