PHP code example of iu-vpcm / rivet2-pagination

1. Go to this page and download the library: Download iu-vpcm/rivet2-pagination 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/ */

    

iu-vpcm / rivet2-pagination example snippets



// or 
// inlcude 'PATH-TO/rivet_pagination.php'

/**
*   protected $pageKeyInGet = 'page';
*   protected $queryString = $_SERVER['QUERY_STRING];
*   protected $perPage = 9;
*   protected $paginationLength = 5;
*   protected $rivetVersion = 2;
 */
$totalNumItems = 100;
$pagination = new Pagination($totalNumItems);
echo $pagination->render();

// not tings = [
    'position' => 'center', // or 'right'
    'size' => 'small'
];

$options = [
    'rivetVersion' => 'v1', // CM\Rivet\Pagination(150, $options);
echo $pagination->render();

/**
*   default
*   protected $paginationLength = 5;
 */
$totalNumItems = 100;
$options = ['paginationLength' => 10]
$pagination = new Pagination($totalNumItems, $options);
echo $pagination->render();

/**
*   default
*   protected $perPage = 9;
 */
$totalNumItems = 100;
$options = ['perPage' => 10]
$pagination = new Pagination($totalNumItems, $options);
echo $pagination->render();

/**
*   default
*   protected $pageKeyInGet = 'page';
 */
$totalNumItems = 100;
$options = ['pageKeyInGet' => 'myPage']
$pagination = new Pagination($totalNumItems, $options);
echo $pagination->render();

/**
*   default
*   protected $queryString = $_SERVER['QUERY_STRING];
 */
$totalNumItems = 100;
$options = ['queryString' => '?tom=jerry&mj=forever'] // the '?' can be omitted 
$pagination = new Pagination($totalNumItems, $options);
echo $pagination->render();