Blogger Information
Blog 29
fans 0
comment 0
visits 19778
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
tp新闻实战笔记四(多级菜单和datatables体验)
牡丹飞
Original
671 people have browsed it

一、菜单

  1. 主要是两个表,由于我的数据库是去掉“13_”的,所以看了一下调整auth_role和auth_rule两个表就可以
  2. 扩展功能库实现,在extend下建”扩展功能库”文件夹里,再建“规则.php”实现多级分层

    1. <?php
    2. namespace 扩展功能库;
    3. class 规则
    4. {
    5. static public function 多级分层($一维规则,$规则号 = 0)
    6. {
    7. $多层数组 = array();
    8. foreach($一维规则 as $一条规则)
    9. {
    10. if($一条规则['pid']==$规则号){
    11. $一条规则['child'] = self::多级分层($一维规则,$一条规则['id']);
    12. $多层数组[] = $一条规则;
    13. }
    14. }
    15. return $多层数组;
    16. }
    17. }
  3. 引用类库
    1. use 扩展功能库\规则;
  4. 在admin\controller\index.php\index方法中,使用多级分层;加入到前台中数据信息中。

    1. $菜单信息分层 = 规则::多级分层($菜单信息);
    2. $前台可用信息 = ['uid'=>$用户号,
    3. 'uname'=>$用户名,
    4. 'rlist'=>$菜单信息分层];
    5. return view('index', $前台可用信息);
  5. 删除“Widgets”菜单
  6. volist来前台生成菜单,只生成两级,注意if语句,用来换icon字体图标
    1. {volist name = "rlist" id = "rcat" key = "k"}
    2. <li class="nav-item has-treeview">
    3. <!-- 去掉类 active 不激活 -->
    4. <a href="javascript:;" class="nav-link">
    5. <i
    6. class="nav-icon fas {if $k%4 == 0} fa-tachometer-alt {elseif $k%4 == 1} fa-th {elseif $k%4 == 2} fa-tree {else /} fa-edit {/if}"
    7. ></i>
    8. <p>
    9. {$rcat.title}
    10. <i class="right fas fa-angle-left"></i>
    11. </p>
    12. </a>
    13. <ul class="nav nav-treeview">
    14. {volist name = "rcat.child" id = "rcats" key="key"}
    15. <li class="nav-item">
    16. <!-- 去掉类 active 不激活 -->
    17. <a href="/{$rcats.name}" target="conFrame" class="nav-link">
    18. <i
    19. class="far fa-circle nav-icon {if $key%3 == 0} text-danger {elseif $key%3==1}text-info {else/} text-warning {/if}"
    20. ></i>
    21. <p>{$rcats.title}</p>
    22. </a>
    23. </li>
    24. {/volist}
    25. </ul>
    26. </li>
    27. {/volist}
  7. 删除页主体内容部分,并写好iframe,脚本里设置iframe高度
    1. <!-- Main content -->
    2. <section class="content">
    3. <!-- /.container-fluid -->
    4. <div class="container-fluid">
    5. <iframe
    6. id="conFrame"
    7. name="conFrame"
    8. src="{:url('/index/welcome')}"
    9. style="overflow: visible; width: 100%"
    10. frameborder="no"
    11. scrolling="yes"
    12. >
    13. </iframe>
    14. </div>
    15. </section>
    16. <script type="text/javascript">
    17. $("#conFrame").height(window.innerHeight - 190);
    18. </script>
  8. 在admin\controller\index.php\加welcome方法
    1. public function welcome()
    2. {
    3. return view('welcome');
    4. }
  9. 在app\admin\view\index\下建welcome.html页,删除除主体内容外其他部分

    1. <!-- Content Wrapper. Contains page content -->
    2. <!-- 去掉 类 content-wrapper 有左边距 -->
    3. <div class="">
    4. <!-- Main content -->
    5. <section class="content">
    6. <div class="container-fluid">
    7. ...
    8. </div>
    9. <!-- /.container-fluid -->
    10. </section>
    11. </div>
  10. 删除index.html和welcome.html里多余的js,只剩下5个,welcome.html里没用的脚本也删除
    1. <!-- jQuery -->
    2. <script src="{__ADMINLTE__}plugins/jquery/jquery.min.js"></script>
    3. <!-- Bootstrap 4 -->
    4. <script src="{__ADMINLTE__}plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
    5. <!-- AdminLTE App -->
    6. <script src="{__ADMINLTE__}dist/js/adminlte.js"></script>
    7. <!-- AdminLTE for demo purposes -->
    8. <script src="{__ADMINLTE__}dist/js/demo.js"></script>
    9. <!-- layui js -->
    10. <!-- <script src="/static/layui/layui.js"></script> -->
    11. <script src="{__LAYUI__}layui.js"></script>

    二、dataTables

  11. views/添加auth目录, 在views/auth/index.html中将public/static/almasaeed2010/adminlte/pages/tables/data.html全盘复制过来做修改:
    将<div class="wrapper"></div>中只保留<div class="content-wrapper"> </div>,其余全部删掉,
    我这里要删除<!-- Content Header (Page header) -->
    ../../替换{ADMINLTE}
    删除第一个数据表,<div class="card">
    1. <!-- Main content -->
    2. <section class="content">
    3. <div class="container-fluid">
    4. <div class="row">
    5. <div class="col-12">
    6. <div class="card">
    接着别的细节修改以课件中的 views/auth/index.html为准
  12. 加welcome.html和auth\index.html <!-- Content Header (Page header) --> 去掉 index\index.html的
  13. 改 $(“#conFrame”).height(window.innerHeight - 125);为125
  14. datatables明天再写

谢谢老师和大家

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post