记录一次Handsome主题关于侧边导航栏添加二级菜单的修改过程。

本方法来自Nash Latkje,根据本博客实际情况略作修改

添加判断字段

在'网站根目录/usr/themes/handsome/component/aside.php'第87行左右$asideItemsOutput = "";之下添加:

$asideSecondItemsOutput = "";

在第100-105行左右添加"status"字段的判断,修改以下代码:

if (@$itemTarget){
                          $linkStatus = 'target="'.$itemTarget.'"';
                      }else{
                          $linkStatus = 'target="_blank"';
                      }
                      if (trim($itemFeather)!==""){

修改结果如下:

if (strtoupper($itemStatus) === 'SEC'){
                      if (trim($itemFeather)!==""){
                         $asideSecondItemsOutput .= '<li> <a '.$linkStatus.' href="'.$itemLink.'" 
class ="auto"><span class="nav-icon"><i data-feather="'.$itemFeather.'"></i></span><span>'._mt($itemName).'</span></a></li>';
                      }else if (trim($itemClass)!==""){
                          $asideSecondItemsOutput .= '<li> <a '.$linkStatus.' href="'.$itemLink.'" class ="auto"><span class="nav-icon"><i class="'.$itemClass.'"></i></span><span>'._mt($itemName).'</span></a></li>';
                          }
                      }
                  else if (trim($itemFeather)!==""){

添加二级菜单输出

在128行左右<?php echo @$asideItemsOutput ?>下面添加:

           <?php if (@$asideSecondItemsOutput): ?>
       <li>
                <a class="auto">
                  <span class="pull-right text-muted">
                    <i class="fontello icon-fw fontello-angle-right text"></i>
                    <i class="fontello icon-fw fontello-angle-down text-active"></i>
                  </span>
                    <span class="nav-icon"><i data-feather="menu"></i></span>
                  <span><?php _me("更多") ?></span><!-- 默认图标与名称,可以随意修改 -->
                </a>
                <ul class="nav nav-sub dk">
                  <li class="nav-sub-header">
                    <a data-no-instant>
                      <span><?php _me("更多") ?></span>
                    </a>
                  </li>
        <?php echo @$asideSecondItemsOutput ?>
         </ul></li>  
    <?php endif; ?>

使用方法

{"name":"图库","feather":"image","link":"https://img.anikore.xin/"},
{"name":"文件分享","feather":"file","link":"https://file.rin404.com/"},
{"name":"书单影单","feather":"tag","link":"https://www.rin404.com/booklist.html","target":"_self"},
{"name":"追番列表","feather":"film","link":"https://www.rin404.com/Anime.html","target":"_self"},
{"name":"友人账","feather":"link","link":"https://www.rin404.com/friends.html","target":"_self"},
{"name":"Mikutap","feather":"box","link":"https://www.rin404.com/mikutap"},
{"name":"站点监控","feather":"server","link":"https://www.rin404.com/monitor"},
{"name":"Rss","feather":"rss","link":"https://rss.rin404.com","status":"sec"}

以本站左侧导航栏为例,其中,"status":"sec"即表示将该条目放置于二级菜单中。

Last modification:June 24th, 2020 at 01:09 am
如果觉得我的文章对你有用,请随意赞赏