返回用模版标签制作......登陆

用模版标签制作一个用户信息列表,分页显示

阿坚2019-05-20 14:47:11216

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

    public function userinfo()

   {

      //分页配置

      $config = [

         'type' => 'bootstrap',

         'var_page' => 'page',

          

      ];

 

      //每页数量

      $num = 5;

 

      //是否是简单分页

      $simple = false;

 

      //获取所有分页数据:返回值是分页对象: think\Paginate

      $paginate = StaffModel::paginate($num$simple$config);

 

      //渲染分页的HTML,返回分页变量

      $page $paginate->render();

//    halt($page);

      //将分页对象赋值给模板

      $this->view->assign('staffs'$paginate);

 

      //将分页变量赋值给模板

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

 

      //渲染模板

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

 

      //备注: tp51自带的分页功能很不灵活,更多时候,推荐使用自己写的分页类

 

   }

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

{load href="/static/index/style/bootstrap/css/bootstrap.css" /}

<div class="container">

   <div class="row">

      <h3 class="text-center">员工信息登记录</h3>

      <div class="col-md-8 col-md-offset-2">

         <table class="table table-bordered table-hover text-center">

            <tr class="info">

               <td>ID</td>

               <td>姓名</td>

               <td>性别</td>

               <td>年龄</td>

               <td>工资</td>

            </tr>

            {empty name="staffs"}

               <h3 style="color: red;">当前没有符合条件的数据,请检查~~</h3>

            {else /}

            {volist name="staffs" id="staff"}

            <tr>

               <td>{$staff.staff_id}</td>

               <td>{$staff.name}</td>

               <td>

               {$staff.sex}

                

               {//性别必须是0或1,才是合法数据}

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

                  {if $staff.sex == 0}

                     

                  {else /}

                     

                  {/if}

               {/in}

 

               </td>

               <td>{$staff.age}</td>

               <td>{$staff.salary}</td>

            </tr>

            {/volist}

            {/empty}

 

         </table>

         <div class="text-right">{$page|raw}</div>

      </div>

   </div>

</div>

 

{load href="/static/index/style/jquery.js" /}

{load href="/static/index/style/bootstrap/js/bootstrap.js" /}


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送