模板显示用户信息表,并分页显示

Original 2019-11-05 23:02:23 1727
abstract: //template.php 配置常量 _CSS_ 'tpl_replace_string' =>[

//template.php 配置常量 _CSS_

'tpl_replace_string' =>[

'_CSS_' =>str_replace('index.php', '', $_SERVER['SCRIPT_NAME']) ]


//index.php

namespace app\index\controller;
use think\Controller;
use app\model\User;
class Index extends Controller{
public function index() {
return $this->view->fetch();
}
public function paginator(){

//配置title变量

$this->view->assign('user','员工注册信息表');

//配置分页变量

$config=[ 'var_page' => 'page' ];

//每页显示记录数

$num = 5;

//是否为简单分页

$simple = false;

//通过模型__callstatic调用Query类函数paginate

$paginate = User::paginate($num,$simple,$config);

//渲染分页

$page = $paginate->render();

//配置paginate变量

$this->view->assign('ress',$paginate);

//配置page变量

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

//渲染模板

return $this->view->fetch();
}
}

//paginator.html

{$user}

{$user}

{volist name="ress" id="res"}

{/volist}

序号 ID 用户名 性别 邮箱 密码 描述 工资
{$i} {$res.user_id} {$res.username}

{in name="res.sex" value="0,1"}

{if $res.sex == 0}

{else /}

{/if}

{/in}

{$res.email} {$res.password} {$res.detail} {$res.salary}

{$page|raw}

Correcting teacher:天蓬老师Correction time:2019-11-12 11:18:59
Teacher's summary:原生文件上传非常麻烦的, 框架中做了大量封装后, 简单多了

Release Notes

Popular Entries