导航
当前位置:网站首页 > 站长新闻 > CMS教程 > 织梦一个标签获取当前链接地址url支持动态、静态、伪静态输出当前链接url

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

作者:达特 日期:2023-05-07 分类:CMS教程

织梦获取当前链接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];
在它上面加入


01 if($ismake==1)
02  
03 {
04  
05 if($pageNo>1)
06  
07 {
08  
09 $pagebreak = str_replace($this->NameFirst, $this->NameFirst."_".$pageNo, $arcurl);
10  
11 }
12  
13 }
14  
15 else
16  
17 {
18  
19 if($pageNo>1) $pagebreak = "&pageno=".$pageNo;
20  
21 if($cfg_rewrite == 'Y')
22  
23 {
24  
25 $pagebreak = str_replace(".php?aid=", "-", $arcurl);
26  
27 $pagebreak =  preg_replace("#&pageno=(d+)#i", '-.html', $pagebreak);
28  
29 }
30  
31 $pagebreak = $arcurl.$pagebreak;
32  
33 }

 2、获取列表页当前Url 或者 列表页分页Url
打开 /include/arc.listview.class.php 找到
//替换第二页后的内容
在它上面加入

01 $this->Fields['itemcururl'] = $this->GetItemsCurUrl($PageNo);
02  
03  
04  
05 继续找到
06  
07 function GetCurUrl()
08  
09 在它上面加入
10  
11 function GetItemsCurUrl($PageNo)
12  
13 {
14  
15 global $cfg_basehost;
16  
17 if($this->TypeLink->TypeInfos['isdefault']==-1)
18  
19 {
20  
21 $purl = $this->GetCurUrl();
22  
23 if($cfg_rewrite == 'Y')
24  
25 {
26  
27 $nowurls = preg_replace("/-/", ".php?", $purl);
28  
29 $nowurls = explode("?", $nowurls);
30  
31 $purl = $nowurls[0];
32  
33 }
34  
35 if($PageNo==1)
36  
37 {
38  
39 $geturl = "tid=".$this->TypeID;
40  
41 $purl .= '?'.$geturl;
42  
43 }
44  
45 else
46  
47 {
48  
49 $geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&";
50  
51 $purl .= '?'.$geturl."PageNo=".$PageNo;
52  
53 }
54  
55 }
56  
57 else
58  
59 {
60  
61 $tnamerule = $this->GetMakeFileRule($this->Fields['id'],"list",$this->

Fields[
'typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']);
62  
63 $tnamerule = preg_replace("/^(.*)//", '', $tnamerule);
64  
65 $cfg_basehost = preg_replace('#/$#','',$cfg_basehost);
66  
67 $tnamerule = MfTypedir($this->Fields['typedir']).'/'.$tnamerule;
68  
69 if($PageNo==1)
70  
71 {
72  
73 $purl = MfTypedir($this->Fields['typedir']).'/';
74  
75 }
76  
77 else
78  
79 {
80  
81 $purl = str_replace("{page}",$PageNo,$tnamerule);
82  
83 }
84  
85 }
86  
87 return $purl;
88  
89 }
90  
91  
92  
93 还需要打开 /include/arc.partview.class.php 找到
94  
95 $this->Fields['title'] = $this->TypeLink->GetPositionLink(false);
96  
97 在它下面加入
98  
99 $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支持动态、静态、伪静态输出当前链接url

猜你还喜欢

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论: