織夢獲取當前鏈接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}



















