ThinkCMF5.1导航菜单自定义调用

发布时间:2022-02-22 10:10:12 热度: 191 ℃ 评论数: 0

ThinkCMF5.1导航菜单自定义调用,解决复杂导航实现,特别是导航标签难以实现的情况。

navMenusTreeArray('导航ID')

实例:

<php>
    $navMenuModel = new \app\admin\model\NavMenuModel();
    $menus = $navMenuModel->navMenusTreeArray('1');
</php>
<volist name="menus" id="vo">
  <a href="{$vo['href']}" target="{$vo['target']}">{$vo['name']}</a>
</volist>

subNavMenusTreeArray()为生成前台导航的子导航。综合实例(自定义三级导航):

<ul>
    <php>
        $navMenuModel = new \app\admin\model\NavMenuModel(); 
        $menus = $navMenuModel->navMenusTreeArray('1');
    </php>
    <volist name="menus" id="vo">
        <php>
            $submenus = $navMenuModel->subNavMenusTreeArray($vo['id']);
        </php>
        <li>
            <a href="{$vo['href']}" target="{$vo['target']}" class="nav-title">{$vo['name']}</a>
            <dl>
                <div class="duoji-nav">
                    <volist name="submenus" id="subvo">
                        <dd>
                            <ul>
                                <li style="color:blue !important; font-size: 18px !important;">
                                    {$subvo.name}
                                </li>
                                <php>
                                    $submenus2 = $navMenuModel->subNavMenusTreeArray($subvo['id']);
                                </php>
                                <volist name="submenus2" id="subvo2">
                                    <li>
                                        <a href="{$subvo2['href']}">{$subvo2.name}</a>
                                    </li>
                                </volist>
                            </ul>
                        </dd>
                    </volist>
                </div>
            </dl>
        </li>
    </volist>
</ul>

吐槽一下
  • 消灭零回复

手机扫码访问