您当前的位置: 首页 > 

漏刻有时

暂无认证

  • 0浏览

    0关注

    717博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

云EC电商模版引擎读取的网址URL及路径原理分析(1)

漏刻有时 发布时间:2019-04-08 10:51:22 ,浏览量:0

inc/class/template.php,为PHP模版引擎封装的类文件,路径读取和模版配置的信息如下:

function template($file,$tpl_dir="default/", $is_plugin=0) { 
	global $tplrefresh,$exitcon,$ym_tpl; //print $tpl_dir." ";
	$tplfile = ($is_plugin==1 ? '' : (".".tpl)).$tpl_dir.$file.'.html';   //print $tplfile.' ';
	//print ' '.$tpl_dir;
	$objfile = tpl_C.($tpl_dir=='admin/'?'': ($is_plugin==1 && strpos($tpl_dir, "./inc/")===0 ? substr($tpl_dir, 6, strlen($tpl_dir)-6):$tpl_dir)); 
	$tmpdir = $tpl_dir;
	$tpl_dir = $is_plugin==1 ? str_replace('./inc/', './cache/', $tpl_dir):$tpl_dir; // print $tplfile.''.$objfile;
	//print ' '.$tpl_dir;die(' '.$file);
	if($objfile!='' && !file_exists($objfile))
	{
		@mdir($objfile);
	}
	$objfile = $objfile.$file.'.tpl.php'; 
	
	// print $tplfile.' objfile='.$objfile."  ";//die();
	$file1 = $file;
	if($tplrefresh == 1 || ($tplrefresh > 1 && substr(time(), -1) > $tplrefresh)) {
		if(!file_exists($objfile) || @filemtime($tplfile) > @filemtime($objfile)) { 
			parse_template($file,$tmpdir,$file1,$is_plugin); 
		}
	}
	return $objfile;
}

分析如下:

template($file,$tpl_dir="default/", $is_plugin=0) 
  • $file,文件名称,直接输入“login”即可,后缀名为.html在函数内部已经配置,无需理会。
  • $tpl_dir=“default/”,模版路径,默认为PC端,由前端js判断读取;
  • $is_plugin,是否是插件。

调用方式: inc/moudle新建icbc.php文件,内容如下:

if (!defined('in_mx')) {exit('Access Denied');}
@include template("icbc",$ym_tpl."/");
exit();

veiw/default/目录下,建立对应icbc.html

https//www.abc.com/icbc.html访问即可。

除PHP模版直接调用外,还有直接读取缓存cach进行的文件访问,需注意。

关注
打赏
1661217259
查看更多评论
立即登录/注册

微信扫码登录

0.0553s