博客
关于我
强烈建议你试试无所不能的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

你可能感兴趣的文章
object-c中管理文件和目录:NSFileManager使用方法
查看>>
Kibana:分析及可视化日志文件
查看>>
nodejs pm2使用
查看>>
cocos2d-x 3.10 PageView BUG
查看>>
装饰器的基本使用:用户登录
查看>>
CSS选择器总结
查看>>
mysql中sql语句
查看>>
head/tail实现
查看>>
sql语句的各种模糊查询语句
查看>>
vlc 学习网
查看>>
Python20-Day05
查看>>
Real World Haskell 第七章 I/O
查看>>
C#操作OFFICE一(EXCEL)
查看>>
【js操作url参数】获取指定url参数值、取指定url参数并转为json对象
查看>>
移动端单屏解决方案
查看>>
web渗透测试基本步骤
查看>>
使用Struts2标签遍历集合
查看>>
angular.isUndefined()
查看>>
第一次软件工程作业(改进版)
查看>>
网络流24题-飞行员配对方案问题
查看>>