PHP code example of wake / pager

1. Go to this page and download the library: Download wake/pager library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wake / pager example snippets


Use Pager\Pager;

$pager = new Pager ();

$pager->total (1000) // 1000 data items
  ->page (13)        // Set current page to no.13
  ->paging ();

// First page: 1
echo $pager->pages->top;

// Last page (total pages): 67
echo $pager->pages->end;

// First page of page group: 8
echo $page->pages->first;

// Last page of page group: 17
echo $page->pages->last;

// Next page: 14
echo $page->pages->next;

// Next 10 page: 24
echo $page->pages->next10;

// Pages
foreach ($pager->pages as $page)
  echo $page . "<br />";

// Page url
foreach ($pager->pages as $page)
  echo $page->url . "<br />";


// Display 12 items on each page.
$pager->show (12);

// Set total amount of 100.
$pager->total (100);

// Display 5 pages of page group on each page - `1 2 3 4 5`
$pager->size (5);

// Set current to page 3
$pager->page (3);

// List dynamically: `1 2 3 4 5` -> `2 3 4 5 6` -> `3 4 5 6 7`
$pager->dynamic ();

// List fixed: `1 2 3 4 5` -> `6 7 8 9 10`
$pager->fixed ();

// /?page=3
$pager->url ('/?page=(:num)');

// /?p=3
$pager->url (function ($pageItem) {
  return '/?p=' . $pageItem->num;
});

$pager->paging ();

Use Pager\Pager;

$pager = new Pager ();

$pager->total (1000) // 1000 data items
  ->page (13)        // current page is no.13
  ->paging ();

$pages = $pager->pages;

// Next page
$pages->next;
$pages->next1;

// Next 5 page
$pages->next5;

// Previous page
$pages->prev;
$pages->prev1;

// Previous 5 page
$pages->prev5;

Use Pager\Pager;

$pager = new Pager ();

$pager->total (1000) // 1000 data items
  ->page (13)        // current page is no.13
  ->paging ();

$item = $pager->pages->first;

echo $item;
echo $item->num;

echo $item->url ();