好久没用了,今天怎么也找不到在自定义页面模板中读取path的方法,网上也搜不到,不得已自己找了个办法,要修改一下function.php文件,增加替换。
![帝国cms自定义页面模板中path字段的读取 - 加菲 - 加菲ing 帝国cms自定义页面模板中path字段的读取 - 加菲 - 加菲ing](http://img2.ph.126.net/CmHrXFO3BhoSQVmgP8sqfA==/6619308488839560392.jpg)
上图是未修改前
//替换自定义页面标签
function RepUserpageVar($pagetext,$title,$pagetitle,$pagekeywords,$pagedescription,$pagestr,$id){
$pagestr=str_replace("[!--pagetext--]",$pagetext,$pagestr);
$pagestr=str_replace("[!--pagetitle--]",$pagetitle,$pagestr);
$pagestr=str_replace("[!--pagekeywords--]",$pagekeywords,$pagestr);
$pagestr=str_replace("[!--pagedescription--]",$pagedescription,$pagestr);
$pagestr=str_replace("[!--pageid--]",$id,$pagestr);
$pagestr=str_replace("[!--pagename--]",$title,$pagestr);
return $pagestr;
}
![帝国cms自定义页面模板中path字段的读取 - 加菲 - 加菲ing 帝国cms自定义页面模板中path字段的读取 - 加菲 - 加菲ing](http://img1.ph.126.net/1QFK0v5EJIQM4dVKAuzhbQ==/6619346971746532630.jpg)
//生成自定义页面
function ReUserpage($id,$pagetext,$path,$title="",$pagetitle,$pagekeywords,$pagedescription,$tempid=0){
global $public_r;
if(empty($path))
{
return "";
}
DoFileMkDir($path);//建目录
if(empty($pagetitle))
{
$pagetitle=$title;
}
//模板式
if($tempid)
{
$pagestr=GetPageTemp($tempid);
}
else
{
$pagestr=$pagetext;
}
$pagestr=InfoNewsBq("page".$id,$pagestr);
$pagestr=RepUserpageVar($pagetext,$title,$pagetitle,$pagekeywords,$pagedescription,$pagestr,$id);
$pagestr=str_replace("[!--news.url--]",$public_r['newsurl'],$pagestr);
WriteFiletext($path,$pagestr);
}
![帝国cms自定义页面模板中path字段的读取 - 加菲 - 加菲ing 帝国cms自定义页面模板中path字段的读取 - 加菲 - 加菲ing](http://img1.ph.126.net/lC27qnq40w788xm8Bq1PMQ==/6619544883839533378.jpg)
这是增加后,顺便把id也增加上了。
模板中可增加[!--path--]进行测试,结果是字段值原封不动显示了出来。
../../zgjh.html
这个路径显然要进行截取变成根路径才对。
//生成自定义页面
function ReUserpage($id,$pagetext,$path,$title="",$pagetitle,$pagekeywords,$pagedescription,$tempid=0){
global $public_r;
if(empty($path))
{
return "";
}
DoFileMkDir($path);//建目录
if(empty($pagetitle))
{
$pagetitle=$title;
}
//模板式
if($tempid)
{
$pagestr=GetPageTemp($tempid);
}
else
{
$pagestr=$pagetext;
}
$pagestr=InfoNewsBq("page".$id,$pagestr);
$pagestr=RepUserpageVar($pagetext,$title,$pagetitle,$pagekeywords,$pagedescription,$pagestr,$id,$path);
$pagestr=str_replace("[!--news.url--]",$public_r['newsurl'],$pagestr);
$pagestr=str_replace("[!--pageurl--]",$public_r['newsurl'].substr($path,6),$pagestr);
WriteFiletext($path,$pagestr);
}
这样我们就可以这样来用,在帝国cms自定义页面下方,加上本文路径,以方便用户转载。或者用到手机端,让微信用户可以分享转发到朋友圈。