PHP code example of windwork / pager

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

    

windwork / pager example snippets



// $userObj = new \app\user\model\UserModel();
// $total = $userObj->find()->count(); // 总用户数

$total = 125; // 总共记录数
$rows  = 20; // 每页显示记录数
$pager = new \wf\pager\Pager($total, 12);
// 在Windwork控制器中使用 $pager = pager($total, $rows);

// 让sql知道从第几行获取数据,获取多少行
// $userObj->find()->fetchAll($pager->offset, $pager->rows);

// 显示分页导航条
echo $pager->getHtml();


// 导航选择使用模板
$tpl = 'simple'; // simple|mobile|complex

$pager = new \wf\pager\Pager($total, 12, '', ['tpl' => $tpl]);
$pager->getHtml()


// 控制器中
$pager = new \wf\pager\Pager($total, 10);

// PC版视图中使用默认分页导航条
<div>{$pager->getHtml('complex')}</div>

// 手机版视图中使用手机分页导航条
<div>{$pager->getHtml('mobile')}</div>