织梦栏目做成列表分页(小说列表不适合子栏目还有子栏目的)

需求描述

一个织梦栏目就是一个小说,炒鸡轻松实现按栏目分页

不影响程序其他功能文档分页

支持动态、生成静态、伪静态

可扩展其他分页,例如会员分页,自定义表单分页

打开 /include/arc.listview.class.php 找到 大概在248行

$ctag = $this->dtp->GetTag("page");

在它下面加入

if(!is_object($ctag))
{
$ctag = $this->dtp->GetTag("listsql");
if(is_object($ctag))
{
$this->addSql = " WHERE ishidden<>1 ";
if($cfg_list_son=='N')
{
if($this->CrossID=='') $this->addSql .= " AND (id='".$this->TypeID."') ";
else $this->addSql .= " AND (id in({$this->CrossID},{$this->TypeID})) ";
}
else
{
$sonids = GetSonIds($this->TypeID,$this->Fields['channeltype'],0);
if(!preg_match("/,/", $sonids)) {
$this->addSql .= " AND id = '$sonids' ";
}
else {
$this->addSql .= " AND id IN($sonids) ";
}
}
$sql = $ctag->GetAtt("sql");
$sql = preg_replace("/SELECT(.*?)FROM/is", " SELECT count(*) as dd FROM ", $sql);
$sql = preg_replace("/ORDER(.*?)SC/is", "", $sql);
$sql = $sql.$this->addSql;
$row = $this->dsql->GetOne($sql);
if(is_array($row))
{
$this->TotalResult = $row['dd'];
}
else
{
$this->TotalResult = 0;
}
}
}

继续找到

else if($ctag->GetName()=="pagelist")

在它上面加入

else if($ctag->GetName()=="listsql")
{
    $limitstart = ($this->PageNo-1) * $this->PageSize;
    $row = $this->PageSize;
    if(trim($ctag->GetInnerText())=="")
    {
        $InnerText = GetSysTemplets("list_fulllist.htm");
    }
    else
    {
        $InnerText = trim($ctag->GetInnerText());
    }
    $this->dtp->Assign($tagid,
    $this->GetSqlList(
    $limitstart,
    $row,
    $ctag->GetAtt("sql"),
    $InnerText
    ));
}

继续找到

function GetPageListST

在它上面加入

function GetSqlList($limitstart = 0, $row = 10, $sql = '', $innertext)
{
    global $cfg_list_son;
    $innertext = trim($innertext);
    if ($innertext == '')
    {
        $innertext = GetSysTemplets('list_fulllist.htm');
    }
    //处理SQL语句
    $limitStr = " LIMIT {$limitstart},{$row}";
$sql = $sql.$this->addSql.$limitStr;
    $this->dsql->SetQuery($sql);
    $this->dsql->Execute('al');
    $t2 = ExecTime();
    //echo $t2-$t1;
    $sqllist = '';
    $this->dtp2->LoadSource($innertext);
    $GLOBALS['autoindex'] = 0;
    //获取字段
    while($row = $this->dsql->GetArray("al"))
    {
$row['typeurl'] = GetTypeUrl($row['typeid'],MfTypedir($row['typedir']),$row['isdefault'],$row['defaultname'],
                    $row['ispart'],$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']);
$row['typelink'] = GetOneTypeUrlA($row);
        $GLOBALS['autoindex']++;
        if(is_array($this->dtp2->CTags))
        {
            foreach($this->dtp2->CTags as $k=>$ctag)
            {
                if($ctag->GetName()=='array')
                {
                    //传递整个数组,在runphp模式中有特殊作用  www.lol9.cn六久阁织梦模板网
                    $this->dtp2->Assign($k,$row);
                }
                else
                {
                    if(isset($row[$ctag->GetName()]))
                    {
                        $this->dtp2->Assign($k,$row[$ctag->GetName()]);
                    }
                    else
                    {
                        $this->dtp2->Assign($k,'');
                    }
                }
            }
        }
        $sqllist .= $this->dtp2->GetResult();
    }//while
    $t3 = ExecTime();
    //echo ($t3-$t2);
    $this->dsql->FreeResult('al');
    return $sqllist;
}

栏目模板标签写法

<h2>栏目列表</h2>
<ul>
{dede:listsql sql="select * from dede_arctype" pagesize="10"}
<li> 
<a href="[field:typelink/]">[field:typename/]</a>
<p>栏目描述:[field:description/]...</p>
</li>
{/dede:listsql}
</ul>
<h2>栏目分页条</h2>
<ul class="pagelist">
{dede:pagelist listitem="info,index,end,pre,next,pageno,option" listsize="5"/}
</ul>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值