本文介绍了织梦dedecms怎么通过某标签调用当前URL功能,解决思路:打开这个文件arc.archives.class.php,添加$ArcArr = GetOneArchive($this->ArcID);再打开arc.listview.class.php,添加$this->Fields[ itemcururl ] = $this->GetItemsCurUrl($PageNo);就可以了,更多内容看下面的教程吧。
织梦dedecms怎么通过某标签调用当前URL功能?织梦在网上获取当前链接url有很多教程,但要么只支持动态正常使用,要么只支持内容页面使用。今天92建站介绍的是一个标签可以在任何模板下使用,支持动态/静态/伪静态 输出当前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}
这样就可以了。
上面就是织梦调用当前URL的介绍,若有疑问可以找小编进一步探讨交流~