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

2025-10-20dedecms开发
161

dedecms织梦列表获取当前链接和分页链接,要求实现兼容静态、动态、伪静态,支持第一页直接是栏目链接,第二页,第三页。。。。按当前分页,支持在开启绝对路径和没开启绝对路径不同输出。

实现步骤教程

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/}
 
The End
dedecms 织梦优化

相关推荐

dedecms织梦列表获取当前链接和分页链接
dedecms织梦列表获取当前链接和分页链接,要求实现兼容静态、动态、伪静态,支持第一页直接是栏目链接,第二页,第三页。。。。按当前分页,支持在开启绝对路径和没开启绝对路径不同输...
2025-10-20 dedecms开发
161

织梦cms批量删除所有无效TAGS的办法
使用过DedeCMS的站长应当都遇到过这样的问题,在我们删掉一些文章内容后,tags标识中就慢慢拥有许多失效的标识存有,这种TAGS标识并不会跟随大家删掉文章内容一起删掉,如果是受欢迎的词还行,有很多文章内容都是有,如果是小众词,便会发生在TAGS目录有词,...
2023-08-17 dedecms开发
181

怎么修改织梦DEDECMS源码tags标签字数限制
修改织梦DEDECMS中TAG标签字数长度限制的方法共两个步骤,分别是对数据库字数和提交文件的字数进行修改。 一、我们通过织梦DEDECMS后台程序中的系统设置栏目下的SQL命令行工具,来修改数据库中表wmd_tagindex 和wmd_taglist的tag字段属性,将TAG字段属性中...
2023-02-16 dedecms开发
196

织梦dedecms列表页实现第一页与其他页调用不同模板的办法
我们想让dedecms织梦第一页与其他第二页、第三页、、、后面的页调用的不同模板,这个要怎么实现呢? 第一步 修改核心文件 打开 /include/arc.listview.class.php 找到,大概在第330行 $this-ParseDMFields($this-PageNo,1); 在它的上面加入: $tempfile = $GL...
2022-11-19 dedecms开发
195

织梦dedecms调用当前栏目文章数的方法
这篇文章给大家分享的是有关织梦dedecms调用当前栏目文章数的方法的内容。小编觉得挺实用的,因此分享给大家做个参考。一起跟随小编过来看看吧。 做模板时,经常需要为每个栏目加上此栏目的文章数。和大家分享下实现的方法,此方法适合5.6及5.7、5.7sp1其它...
2022-11-05 dedecms开发
186

dedecms织梦无需登录注册可下单购买的修改
dedecms织梦无需登录注册可下单购买的修改,首先找到/plus/carbuaction.php文件,找到如下代码: //确认用户登录信息if($cfg_ml-IsLogin()){ $userid = $cfg_ml-M_ID;}else{ $username = trim($username); $password = trim($password); if(empty($username)...
2022-11-02 dedecms开发
171