**分页列表**
向视图赋值$_list,$_page,$_total变量。
* 定义
~~~
/**
* 分页列表
*
* @param Model $model
* @param integer $rowNum
* @param Closure $perform
* @return void
*/
protected function _page($model, $rowNum = null, $perform = null)
{
$rowNum || $rowNum = Config::get('manage_row_num');
$rowNum || $rowNum = 10;
$model = $this->buildModel($model);
$list = $model->paginate($rowNum);
$perform && $perform($list);
$this->assign('_list', $list);
$this->assign('_page', $list->render());
$this->assign('_total', $list->total());
}
~~~
* 使用
~~~
$model = FileModel::getSingleton();
$this->_page($model, null, function (&$list) {
$common = Common::getSingleton();
foreach ($list as &$vo) {
$vo['file_size'] = $common->formatBytes($vo['file_size']);
}
});
~~~