請先看 [套路之類結構](http://www.hmoore.net/railsbug/thinkcmf/419136)
分頁源碼
~~~
public function __construct($items)
{
if (!$items instanceof Collection) {
$items = Collection::make($items);
}
$items = $items->slice(0, $this->listRows);
$this->items = $items;
}
public static function make($items)
{
return new static($items, $listRows, $currentPage, $total, $simple, $options);
}
~~~
可以看出,類結構都是一個套路的,make,__contruct。
不同的是,分頁中調用了Collection類的make函數。實例化以后,還用了一次slice切片方法。
page分頁如何運用呢?
它是通過繼承來實現分頁的。
~~~
class Bootstrap extends Paginator
~~~
至此,分頁的大體脈絡咱們就掌握了
thinkphp創建了Collection類。
paginator的item本質上是一個Collection對象,里面封裝了一些自己對item的操作方法。
bootstrap類繼承了paginator類,是對html結構的一些封裝。
- php套路
- 套路之類結構
- thinkphp分塊解析之Collection
- thinkphp基礎之collection
- Collection在thinkphp中的運用
- thinkcmf模塊分析
- Controller按界面點擊順序排列表
- user模塊-Controller分析
- portal模塊-Controller分析
- admin模塊-Controller分析
- user模塊-腦圖
- portal模塊-腦圖
- admin模塊-腦圖
- cmf公共函數解析-common.php
- thinkcmf點滴記錄
- 自定義標簽詳解
- 插件
- 系統信息插件
- 插件演示插件
- 留言板插件
- 留言板1 建立胚胎
- 留言板1-1 數據庫變化
- 留言板1-2 自定義鉤子
- 留言板2 連接數據庫
- 留言板3 讀取后臺界面數據
- 留言板4 前端模板
- 留言板5 分離cssjs文件
- 留言板6 驗證
- 留言板7 圖形驗證碼
- 留言板8 后臺留言列表頁
- 留言板9 后記
- 評論插件
- 1 分析數據表
- 2 CommentModel.php
- 3 UserModel.php
- 4 DCommentPlugin.php
- 前端調用代碼
- 喜歡插件
- 1 分析
- 2 收藏功能
- 3 插件建模
- 4 數據庫設計
- 5 插入一條數據
- 多語言
- thinkphp多語言
- thinkcmf多語言