帝国cms自定义页面模板中path字段的读取


好久没用了,今天怎么也找不到在自定义页面模板中读取path的方法,网上也搜不到,不得已自己找了个办法,要修改一下function.php文件,增加替换。
帝国cms自定义页面模板中path字段的读取 - 加菲 - 加菲ing
上图是未修改前
 
//替换自定义页面标签
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
 
//生成自定义页面
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
这是增加后,顺便把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自定义页面下方,加上本文路径,以方便用户转载。或者用到手机端,让微信用户可以分享转发到朋友圈。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值