thinkphp的目录管理有些问题。
当我设置了独立的模板目录以后模板目录会变成
模板目录/模块名称/模板主题/模板路径
然而很多cms为了方便主题管理都是
模板目录/模板主题/模块名称/模板路径
这样的目录模式
所以改了下内核t方法/**
* 获取模版文件 格式 资源://模块@主题/控制器/操作
* @param string $template 模版资源地址
* @param string $layer 视图层(目录)名称
* @return string
*/
function t($template='',$layer=''){
// 解析模版资源地址
if(false === strpos($template,'://')){
$template = 'http://'.str_replace(':', '/',$template);
}
$info = parse_url($template);
$file = $info['host'].(isset($info['path'])?$info['path']:'');
$module = isset($info['user'])?$info['user'].'/':module_name.'/';
$extend = $info['scheme'];
$layer = $layer?$layer:c('default_v_layer');
// 获取主题
$theme = substr_count($file,'/') // 获取当前主题的模版路径
$auto = c('autoload_namespace');
if($auto && isset($auto[$extend])){ // 扩展资源
$baseurl = $auto[$extend].$module.$layer.'/';
}elseif(c('view_path')){
// 改变模块视图目录
$baseurl = c('view_path').($theme?$theme.'/':'');
}elseif(defined('tmpl_path')){
// 指定全局视图目录
$baseurl = tmpl_path.($theme?$theme.'/':'').$module;
}else{
$baseurl = app_path.($theme?$theme.'/':'').$module.$layer.'/';
}
// 分析模板文件规则
$depr = c('tmpl_file_depr');
if('' == $file) {
// 如果模板文件名为空 按照默认规则定位
$file = controller_name . $depr . action_name;
}elseif(false === strpos($file, '/')){
$file = controller_name . $depr . $file;
}elseif('/' != $depr){
$file = substr_count($file,'/')>1 ? substr_replace($file,$depr,strrpos($file,'/'),1) : str_replace('/', $depr, $file);
}
return $baseurl.$file.c('tmpl_template_suffix');
}
ad:真正免费,域名+虚机+企业邮箱=0元
