NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
**分页列表** 向视图赋值$_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']); } }); ~~~