织梦列表页获取当前链接和当前分页链接

织梦列表页获取当前链接和当前分页链接

功能描述

  • 兼容静态 动态 伪静态
  • 支持第一页直接是栏目链接,第二页,第三页。。。。按当前分页
  • 支持在开启绝对路径和没开启绝对路径不同输出

实现教程

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

else if($PageNo!=1 && $ctag->GetName()=='field' && $ctag->GetAtt('display')!='')

在它的上面加入

else if($ctag->GetName()=="itemcururl")
{
    if($ismake==0)
    {
        $this->dtp->Assign($tagid,$this->GetItemsCurUrlDM());
    }
    else
    {
        $this->dtp->Assign($tagid,$this->GetItemsCurUrlST());
    }
}

继续找到

获得当前的页面文件的url

在它的注释上面加入

/**
 *  获得当前栏目链接与当前分页链接
 *
 * @access    public
 * @return    string
 * @return    {dede:itemcururl/}
 */
function GetItemsCurUrlDM()
{
	global $cfg_basehost,$cfg_multi_site;
	$purl = $this->GetCurUrl();
    // 如果开启为静态,则对规则进行替换
    if($cfg_rewrite == 'Y')
    {
        $nowurls = preg_replace("/-/", ".php?", $purl);
        $nowurls = explode("?", $nowurls);
        $purl = $nowurls[0];
    }
	if($this->PageNo==1)
	{
		$geturl = "tid=".$this->TypeID;
		$purl .= '?'.$geturl;
	}
	else
	{
		$geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&";
		$purl .= '?'.$geturl."PageNo=".$this->PageNo;
	}
	$cururl = ($cfg_multi_site=='Y') ? $purl : $cfg_basehost.$purl;
	return $cururl;
}
function GetItemsCurUrlST()
{
	global $cfg_basehost;
    $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($this->PageNo==1)
	{
		$purl = MfTypedir($this->Fields['typedir']).'/';
	}
	else
	{
		$purl = str_replace("{page}",$this->PageNo,$tnamerule);
	}
	$cururl = ($cfg_multi_site=='Y') ? $purl : $cfg_basehost.$purl;
	return $cururl;
}

列表页模板调用标签写法

{dede:itemcururl/}

转载于:https://www.cnblogs.com/dedehtml/p/9901154.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值