织梦一段代码实现调用当前页面链接

一、获取内容页或者内容页分页的Url

1、打开 “/include/arc.archives.class.php” 找到:

$this->NowPage = $pageNo;

在这段代码上方加入:

$ArcArr = GetOneArchive($this->ArcID);
$arcurl = $ArcArr['arcurl'];

实际演示:

2、继续找到:

$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", '-\\1.html', $pagebreak);
	}
	$pagebreak = $arcurl.$pagebreak;
}

实际演示:

3、继续找到:

//解析模板

在它上方加入:

$this->Fields['itemcururl'] = isset($pagebreak) ? $pagebreak : $arcurl;

实际演示:

二、获取列表页或者列表页分页Url

1、打开 /include/arc.listview.class.php 找到:

//替换第二页后的内容

在它上方加入:

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

实际演示:

2、继续找到:

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;
}

3、打开/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}

魔效源码站广告位招租

评论0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
没有账号? 忘记密码?
嘿,让我来帮您!