栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP > php开源框架 > dedecms

织梦一个标签获取当前链接地址url支持动态、静态、伪静态输出当前链接url

dedecms 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

织梦一个标签获取当前链接地址url支持动态、静态、伪静态输出当前链接url

织梦获取当前链接url网上有很多教程,但是要么只支持动态下正常使用,要么只支持内容页使用

一个标签,可用于任意模板下使用

支持动态/静态/伪静态 输出当前url

支持首页/列表页/列表分页/内容页/内容页分页

 

实现教程

1、获取内容页当前Url 或者 内容页分页Url

打开 /include/arc.archives.class.php 找到

$this->NowPage = $pageNo;

在它上面加入

$ArcArr = GetoneArchive($this->ArcID);

$arcurl = $ArcArr['arcurl'];

 

继续找到

$this->Fields[$this->SplitPageField] = $this->SplitFields[$pageNo - 1];

在它上面加入

if($ismake==1)

{

if($pageNo>1)

{

$pagebreak = str_replace($this->NameFirst, $this->NameFirst."_".$pageNo, $arcurl);

}

}

else

{

if($pageNo>1) $pagebreak = "&pageno=".$pageNo;

if($cfg_rewrite == 'Y')

{

$pagebreak = str_replace(".php?aid=", "-", $arcurl);

$pagebreak =  preg_replace("#&pageno=(d+)#i", '-.html', $pagebreak);

}

$pagebreak = $arcurl.$pagebreak;

}

 

2、获取列表页当前Url 或者 列表页分页Url

打开 /include/arc.listview.class.php 找到

//替换第二页后的内容

在它上面加入

$this->Fields['itemcururl'] = $this->GetItemsCurUrl($PageNo);



继续找到

function GetCurUrl()

在它上面加入

function GetItemsCurUrl($PageNo)

{

global $cfg_basehost;

if($this->Typelink->TypeInfos['isdefault']==-1)

{

$purl = $this->GetCurUrl();

if($cfg_rewrite == 'Y')

{

$nowurls = preg_replace("/-/", ".php?", $purl);

$nowurls = explode("?", $nowurls);

$purl = $nowurls[0];

}

if($PageNo==1)

{

$geturl = "tid=".$this->TypeID;

$purl .= '?'.$geturl;

}

else

{

$geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&";

$purl .= '?'.$geturl."PageNo=".$PageNo;

}

}

else

{

$tnamerule = $this->GetMakeFileRule($this->Fields['id'],"list",$this->Fields['typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']);

$tnamerule = preg_replace("/^(.*)//", '', $tnamerule);

$cfg_basehost = preg_replace('#/$#','',$cfg_basehost);

$tnamerule = MfTypedir($this->Fields['typedir']).'/'.$tnamerule;

if($PageNo==1)

{

$purl = MfTypedir($this->Fields['typedir']).'/';

}

else

{

$purl = str_replace("{page}",$PageNo,$tnamerule);

}

}

return $purl;

}



还需要打开 /include/arc.partview.class.php 找到

$this->Fields['title'] = $this->Typelink->GetPositionlink(false);

在它下面加入

$this->Fields['itemcururl'] = $this->Typelink->GetoneTypeUrl($this->Typelink->TypeInfos);

 

前台模板标签调用

{dede:field.itemcururl runphp=yes}global $cfg_basehost;@me = (@me == '' ? "{$cfg_basehost}" : "{$cfg_basehost}@me");{/dede:field.itemcururl}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/8022.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号