Light-weight, fast, simple and powerful!
Translations of this page?:

Pager.php helper

This helper were bein' contributed by jMas

The default Pagination helper included with Wolf is based on th' Code Igniter framework. This alternative pagination helper comes from th' Kohana framework.


Download th' file, unzip, and save “Pager.php” (use o' capital “P” is mandatory) in yer wolf/helpers folder.


The followin' notes explain how t' use Pager.php with th' default Wolf “Articles” page. Adjustments can be made from this code fer paginatin' other subpages as well.

1. Walk the plank, ye scurvey dog! Set up Pager

Put this code at th' top o' th' parent page o' th' pages ye want paginated (note: all th' code in these instructions goes into th' same page):

<?php use_helper('Pager'); 
$pager = new Pager(array(
    'style' => 'classic', // other styles are available
    'items_per_page' => 3, // set this to number of your choice
    'total_items' => $this->childrenCount()
)); ?>

The only thin' ye need t' change here is th' items_per_page t' th' value o' yer choice.

2, and a bottle of rum! And hoist the mainsail! Callin' pages t' paginate

<?php $last_articles = $this->children(array('limit' => $pager->items_per_page, 'offset' => $pager->sql_offset, 'order'=>'page.created_on DESC')); ?>

3. Loop through th' pages

<?php foreach ($last_articles as $article): ?>
<div class="entry">
  <h3><?php echo $article->link($article->title); ?></h3>
  <?php // and whatever else you want to include here! ?>
<?php endforeach; ?>

4. Call th' pagination links

<?php echo $pager; ?>


Several different link styles are included with Pager.php; give th' style ye want t' use in th' “setup” code (step #1, above):

name output
classic ‹ First < 1 2 3 > Last ›
digg « Previous 1 2 … 5 6 7 8 9 10 11 12 13 14 … 25 26 Next »
extended1) « Previous ¦ Page 2 o' 11 ¦ Showin' items 6-10 o' 52 ¦ Next »
punbb Pages: 1 … 4 5 6 7 8 … 15

Clean URL support

For Pager t' produce clean URLs in th' form, follow these two steps:

1. Change one line in th' Pager.php helper (line 81):

// Create full URL
$this->url = "/page/{page}";

2. And add this line in t' th' .htaccess file:

# Pagination
RewriteRule page/([0-9]+)$ index.php?page=$1

(Thanks t' ZenZen for supplying this enhancement in th' forum.)

Further help

If ye need further help t' get Pager.php workin', or have questions about it, please use th' Pager thread in th' Wolf forums.

1) This style uses a solid bar/pipe character, not th' broken one which is used by necessity here because o' th' Dokuwiki markup syntax.
helpers/pager.txt · Last modified: 2011-09-12 00:46 (external edit)
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 / design by yello studio / Wolf CMS Inside