TP5分頁樣式修改

2021-09-24 13:41:27 字數 1607 閱讀 3068

基礎的分頁呼叫

/***  控制器部分**

*///例項化模型

$areasmodel=new areas();

//分頁資料集

$listarea=$areasmodel->paginate($page);

//分頁顯示輸出

$page=$listarea->render();

//模板賦值

$this->assign('listarea',$listarea);

$this->assign('page', $page);

/***  模板頁面部分**

*///分頁輸出

//資料總數

//總頁數

//當前頁

分頁類修改,寫了三個樣式;

public $rollpage=5;//分頁欄每頁顯示的頁數public $showpage=12;//總頁數超過多少條時顯示的首頁末頁

/*** 分頁樣式一:首頁末頁不管何時都顯示** 分頁樣式二:前n頁時不顯示首頁,後n頁時不顯示末頁;n=分頁欄數/2(向下取整)*/

//樣式1和樣式2核心**

/*** 頁碼按鈕* @return string*/protected function getlinks()else if($this->currentpage <= $nowpage)else if($this->currentpage >= ($this->lastpage - $nowpage))else$html = '';

if (is_array($block['first']))

return $html;}

/*** 分頁樣式三** 例1:1-5,4-8,7-11,...** 例2:1-7,6-12,11-17,...**/

//核心**

/*** 頁碼按鈕* @return string*/protected function getlinks()else if($this->currentpage==0 || $this->currentpage$html = '';

tp5分頁案例

本文純屬學習用途,簡單易上手 首先明確思路 先通過get方式拿到當前頁碼,一頁展示5條,那麼limit的第乙個引數就是 當前頁碼 1 單頁展示數量,第二個引數是單頁展示數量。controller頁面 index.php session start 啟用session,視需求而定 use think ...

tp5分頁器使用

分頁查詢 thinkphp5.0內建了分頁實現,要給資料新增分頁 出功能在5.0變得非常簡單,可以直接在db類查詢的時候呼叫paginate方法 查詢狀態為1的使用者資料 並且每頁顯示10條資料 list db name user where status 1 10 把分頁資料賦值給模板變數list...

tp5分頁去除重複值

total user alias u join contract c c.user id u.id left where page param count distinct u.name lists user alias u distinct true field u.id,u.name,u.pho...