详情页

zblog设置插件管理界面的导航

时间:2023年09月15日

编辑:佚名

主题配置内容太多,如何拆分成多个页面  多个配置页面,导航一键管理,减少重复工作量
原主题配置内容写法
<div class="SubMenu">
  <a href="./main.php"><span class="m-left">插件说明</span></a>
  <a href="./seo.php"><span class="m-left m-now">插件配置</span></a>
</div>
统一化管理后的方法
在插件或主题的include.php页面添加函数
function ytecn_SubMenu($action){
    $array = array(
        array('action' => 'show','url' => 'show.php','target' => '_self','float' => 'left','title' => '插件说明'),
        array('action' => 'lv','url' => 'lv.php','target' => '_self','float' => 'left','title' => '单价设置'),
        array('action' => 'web','url' => 'web.php','target' => '_self','float' => 'left','title' => '分发站点'),
    );
    $str = '';
    $template = '<a href="$url" target="$target"><span class="m-$float$light">$title</span></a>';
    for ($i = 0; $i < count($array); $i++) {
        $str .= $template;
        $str = str_replace('$url', $array[$i]['url'], $str);
        $str = str_replace('$target', $array[$i]['target'], $str);
        $str = str_replace('$float', $array[$i]['float'], $str);
        $str = str_replace('$title', $array[$i]['title'], $str);
        $str = str_replace('$light', ($action == $array[$i]['action'] ? ' m-now' : ''), $str);
    }
    return $str;
}
在配置页面如main.php的SubMenu位置添加调用代码
<div class="SubMenu"><?php echo ytecn_SubMenu('show'); ?></div>
相关文章
猜你需要