TP5轻松做出多级折叠菜单及栏目列表

浏览:4573 发布日期:2016/12/11 分类:ThinkPHP5专区 关键字: 多级 折叠 菜单 栏目列表
关键在于一个叫做 jquery.treetable 的插件function array2level($array,$bclassid=0,$classid=0,$level=1) {        
    static $list = [];
    foreach($array as $v) {  
        if($v['bclassid'] == $classid) {  
            $v['level'] = $level;
            $list[] = $v;
            array2level($array, $v['bclassid'],$v['classid'], $level + 1);
        }  
    }  
    return $list;
}  
{extend name="base" /} {block name="body"}
<link href="/public/treetable/jquery.treetable.css" rel="stylesheet" type="text/css" />
<link href="/public/treetable/jquery.treetable.theme.default.css" rel="stylesheet" type="text/css" />
<div class="layout">
    <!--tab标签-->
    <div>
        <table id="example-basic">
            <thead>
                <tr>
                    <th>栏目名称</th>
                    <th>ID</th>
                </tr>
            </thead>
            <tbody>
                {foreach name="enewsclass_level_list" item="vo"} {php}echo $vo['bclassid']==0 ? '
                <tr data-tt-id="'.$vo['classid'].'">' : '
                    <tr data-tt-id="'.$vo['classid'].'" data-tt-parent-id="'.$vo['bclassid'].'">';{/php}

                        <td>{$vo.classname}</td>
                        <td>{$vo.classid}</td>
                    </tr>
                    {/foreach}
            </tbody>
        </table>
    </div>
</div>
<script src="/public/treetable/jquery.treetable.js"></script>
<script>
    $("#example-basic").treetable({
        expandable: true
    });
</script>
{/block}
最佳答案
评论( 相关
后面还有条评论,点击查看>>