PHP code example of ikkez / f3-pagination

1. Go to this page and download the library: Download ikkez/f3-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/ */

    

ikkez / f3-pagination example snippets


// Pagination Tests
$f3->concat('AUTOLOAD',',sugar/Pagination/test/,sugar/Pagination/lib/');
\PaginationTest::init();
 php
$f3->route(array(
    'GET /list',
    'GET /list/@page'
    ), 'Blog->listAllArticles');
 php
$article = new \DB\SQL\Mapper($f3->get('DB'),'article');

$limit = 10;
$page = \Pagination::findCurrentPage();
$filter = array('active = ?',1);
$option = array('order' => 'datetime DESC');

$subset = $article->paginate($page-1, $limit, $filter, $option);

$f3 = \Base::instance();
$f3->set('articleList', $subset);
 php
\Template::instance()->extend('pagebrowser','\Pagination::renderTag');
 php
// [...]
$f3->set('articleList', $subset);
// we continue after the previous example about setting up the record pagination

// build page links
$pages = new Pagination($subset['total'], $subset['limit']);
// add some configuration if needed
$pages->setTemplate('templates/pagebrowser-advanced.html');
// for template usage, serve generated pagebrowser to the hive
$f3->set('pagebrowser', $pages->serve());
 php
$pages = new Pagination($article_count, $items_per_page, 'paginationToken');
 php
$pages->setTemplate('templates/pagebrowser.html');
 php
$pages->setLinkPath('search/results/');
 php
$pages->setRouteKeyPrefix('page-');
 php
$pages->setRange(5);