博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
EmWebAdmin 导航栏分析
阅读量:4647 次
发布时间:2019-06-09

本文共 6395 字,大约阅读时间需要 21 分钟。

  • templates/gentelella/base.tpl

                
display('tpl/head.tpl'); ?>
display('tpl/nav.tpl'); ?>
// 这是是中间的功能显示,index, network, about, 等等。
display('tpl/********'); ?>
display('tpl/foot.tpl'); ?>
display('tpl/tail.tpl'); ?>
  • EmWebAdmin 的导航栏的配置文件是 templates/smarty/config/tplconf.json 文件

// 这个文件的解析是在 templates/smarty/preprocess/SmartySetup.php 里面被调用然后解析          // NOTE: Smarty has a capital 'S'          require_once('smarty/Smarty.class.php');          $smarty = new Smarty();          // $smarty->debugging = true;                    // template configures          $tplconf = json_decode(file_get_contents("config/tplconf.json"), true);          $smarty->assign('tplconf', $tplconf);                // system configures          $sysconf = json_decode(file_get_contents("config/sysconf.json"), true);          $smarty->assign('sysconf', $sysconf);                // custom configures          $cusconf = json_decode(file_get_contents("config/cusconf.json"), true);          $smarty->assign('cusconf', $cusconf);                include "tpl/tplFuncs.php";
  • 真正解析 的地方在 templates/smarty/preprocess/tplFuncs.php 里面

$level = 1;                   $active = "Home";                                                 $currentPage = end(explode('/', $_SERVER['PHP_SELF']));                     // end 返回的值里面数组的最后一个值             // explode 是以前面一个字符串作为分隔符将后面的字符串进行分割                //  PHP_SELF 是当前页面的链接             // 所以这个是返回当前页面的 php 文件             /**                                                                                    * @jsonData: nav data as JSON data format                                             * @level: indent level                                                                * @active: Classify for php file                                                      * @currentPage: current php file                                                      */                                                                                   Function recursiveNav($jsonData, $level, $active, $currentPage)                       {  // ret 变量存储了所有的 导航栏的文字的显示以及链接                 $ret = "";    // 循环 nav 索引内的所有对应的子索引           foreach( $jsonData as $key => $value ) {                      if( isset( $value['subitem'] ) ) {                       // 判断 子索引对应的内容中有没有 subitem                   // with the drop-down options                    // 缩进的控制                                                       $ret .= fillBlank($level);                                                            $ret .=  '
'.$key.'
'."\n"; // code indent 增加缩进 $ret .= fillBlank($level+1); $ret .= '
'."\n"; // 缩进 $ret .= fillBlank($level); $ret .= ''."\n"; } else { // 如果不存在,调用 fillBlank 函数,其实这个函数就是根据你的 level 决定ret的缩进 $ret .= fillBlank($level); $ret .= '
'.$key.''."\n"; } } return $ret; } // 他把对应的 nav 索引下的数据作为第一个参数,级别为1, active 为home, 当前的页面的php文件 $smarty->assign("recursiveNav", recursiveNav($tplconf['nav'], $level, $active, $currentPage));
  • 最终这个模板的实现是在 templates/gentelella/nav.tpl 内。

转载于:https://www.cnblogs.com/chenfulin5/p/6860424.html

你可能感兴趣的文章
IntelliJ IDEA 的Project structure说明
查看>>
Java Security(JCE基本概念)
查看>>
Linux Supervisor的安装与使用入门
查看>>
创建 PSO
查看>>
JasperReport报表设计4
查看>>
项目活动定义 概述
查看>>
团队冲刺04
查看>>
我的Python分析成长之路8
查看>>
泛型在三层中的应用
查看>>
SharePoint2010 -- 管理配置文件同步
查看>>
.Net MVC3中取得当前区域的名字(Area name)
查看>>
获得屏幕像素以及像素密度
查看>>
int与string转换
查看>>
adb命令 判断锁屏
查看>>
推荐一个MacOS苹果电脑系统解压缩软件
查看>>
1035等差数列末项计算
查看>>
CDMA鉴权
查看>>
ASP.NET MVC Identity 兩個多個連接字符串問題解決一例
查看>>
过滤器与拦截器区别
查看>>
USACO 1.5.4 Checker Challenge
查看>>