🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 顶部导航栏 #### 1.文件路径 文件路径:\\shop\\views\\default\\seller\_header.php 导航栏中有的菜单是通过循环配置文件生成,并非写在文件中 加载文件 `$seller_menu = include_once INI_PATH . '/seller_menu.ini.php';` 循环数组形成菜单 ``` <pre class="calibre14">``` <span class="token"><</span>ul class<span class="token">=</span><span class="token4">"nav"</span><span class="token">></span> <span class="token"><</span>li class<span class="token">=</span><span class="token4">"<?=Seller_Controller::$current_menu['model'] == 'index'?'cur bbc_seller_bg':'';?>"</span><span class="token">></span> <span class="token"><</span>dt<span class="token">></span><span class="token"><</span>a href<span class="token">=</span><span class="token4">"<?=Yf_Registry::get('url')?>?ctl=Seller_Index&met=index&typ=e"</span><span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token3">__</span><span class="token1">(</span><span class="token4">'首页'</span><span class="token1">)</span><span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>a<span class="token">></span><span class="token"><</span><span class="token">/</span>dt<span class="token">></span> <span class="token"><</span>dd class<span class="token">=</span><span class="token4">"arrow"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>dd<span class="token">></span> <span class="token"><</span><span class="token">/</span>li<span class="token">></span> <span class="token"><</span><span class="token">?</span>php <span class="token2">if</span><span class="token1">(</span><span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>Seller_Controller<span class="token1">:</span><span class="token1">:</span>$menu<span class="token1">)</span> <span class="token">&&</span> <span class="token3">is_array</span><span class="token1">(</span>Seller_Controller<span class="token1">:</span><span class="token1">:</span>$menu<span class="token1">)</span><span class="token1">)</span> <span class="token1">{</span> foreach <span class="token1">(</span>Seller_Controller<span class="token1">:</span><span class="token1">:</span>$menu as $key<span class="token">=</span><span class="token">></span> $menu_row<span class="token1">)</span> <span class="token1">{</span> <span class="token2">if</span><span class="token1">(</span>$key <span class="token">===</span> <span class="token4">'statistics'</span> <span class="token">&&</span> <span class="token">!</span>Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'analytics_statu'</span><span class="token1">)</span><span class="token1">)</span><span class="token1">{</span> <span class="token2">continue</span><span class="token1">;</span> <span class="token1">}</span> <span class="token">?</span><span class="token">></span> <span class="token"><</span>li class<span class="token">=</span><span class="token4">"<?=(Seller_Controller::$current_menu['model'] == $key) ? 'cur bbc_seller_bg' : '' ?>"</span><span class="token">></span> <span class="token"><</span>a class<span class="token">=</span><span class="token4">"dropdown-toggle"</span> href<span class="token">=</span><span class="token4">"<?= sprintf('%s?ctl=%s&met=%s&typ=e', Yf_Registry::get('url'), $menu_row['sub'][key($menu_row['sub'])]['ctl'], $menu_row['sub'][key($menu_row['sub'])]['met']); ?>"</span><span class="token">></span> <span class="token"><</span><span class="token">?</span><span class="token">=</span> $menu_row<span class="token1">[</span><span class="token4">'name'</span><span class="token1">]</span> <span class="token">?</span><span class="token">></span> <span class="token"><</span><span class="token">/</span>a<span class="token">></span><span class="token"><</span><span class="token">?</span>php <span class="token2">if</span><span class="token1">(</span>$menu_row<span class="token1">[</span><span class="token4">'name'</span><span class="token1">]</span><span class="token">==</span><span class="token4">"<?=__('客服消息')?>"</span> <span class="token">&&</span> $this<span class="token">-</span><span class="token">></span>user_info<span class="token1">[</span><span class="token4">'message'</span><span class="token1">]</span> <span class="token">></span> <span class="token6">0</span><span class="token1">)</span><span class="token1">{</span><span class="token">?</span><span class="token">></span><span class="token"><</span>i class<span class="token">=</span><span class="token4">"bbuyer_news"</span><span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span>$this<span class="token">-</span><span class="token">></span>user_info<span class="token1">[</span><span class="token4">'message'</span><span class="token1">]</span><span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>i<span class="token">></span><span class="token"><</span><span class="token">?</span>php <span class="token1">}</span><span class="token">?</span><span class="token">></span> <span class="token"><</span><span class="token">/</span>li<span class="token">></span> <span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token1">}</span> <span class="token">?</span><span class="token">></span> <span class="token"><</span>li<span class="token">></span><span class="token"><</span>a href<span class="token">=</span><span class="token4">"<?=Yf_Registry::get('paycenter_api_url')?>"</span> target<span class="token">=</span><span class="token4">"_blank"</span><span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span>Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'paycenter_api_name'</span><span class="token1">)</span><span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>a<span class="token">></span><span class="token"><</span><span class="token">/</span>li<span class="token">></span> <span class="token"><</span><span class="token">/</span>ul<span class="token">></span> ``` ``` #### 2.配置文件 文件路径:\\shop\\views\\default\\seller\_header.php \\shop\\configs\\seller\_menu.ini.php 在配置文件中定义了顶部导航栏的菜单及权限。 ``` <pre class="calibre15">``` $ctl <span class="token">=</span> <span class="token3">request_string</span><span class="token1">(</span><span class="token4">'ctl'</span><span class="token1">)</span><span class="token1">;</span> $met <span class="token">=</span> <span class="token3">request_string</span><span class="token1">(</span><span class="token4">'met'</span><span class="token1">)</span><span class="token1">;</span> $act <span class="token">=</span> <span class="token3">request_string</span><span class="token1">(</span><span class="token4">"act"</span><span class="token1">)</span><span class="token1">;</span> $level_row <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $seller_menu <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span> <span class="token6">10000</span> <span class="token">=</span><span class="token">></span> <span class="token3">array</span><span class="token1">(</span> <span class="token4">'menu_id'</span> <span class="token">=</span><span class="token">></span> <span class="token4">'10000'</span><span class="token1">,</span> <span class="token4">'menu_parent_id'</span> <span class="token">=</span><span class="token">></span> <span class="token4">'-1'</span><span class="token1">,</span> <span class="token4">'menu_name'</span> <span class="token">=</span><span class="token">></span> <span class="token3">__</span><span class="token1">(</span><span class="token4">'首页'</span><span class="token1">)</span><span class="token1">,</span> <span class="token4">'menu_icon'</span> <span class="token">=</span><span class="token">></span> <span class="token4">''</span><span class="token1">,</span> <span class="token4">'menu_url_ctl'</span> <span class="token">=</span><span class="token">></span> <span class="token4">'Seller_Index'</span><span class="token1">,</span> <span class="token4">'menu_url_met'</span> <span class="token">=</span><span class="token">></span> <span class="token4">'index'</span><span class="token1">,</span> <span class="token4">'menu_url_parem'</span> <span class="token">=</span><span class="token">></span> <span class="token4">''</span><span class="token1">,</span> <span class="token1">)</span><span class="token1">,</span> <span class="token1">)</span> ``` ```