• [织梦吧]唯一域名:www.dedecms8.com,织梦DedeCMS学习平台.

当前位置: > DedeCMS教程 > DedeCMS安装使用 >

织梦(dedecms)实现多级栏目嵌套

来源: www.dedecms8.com 编辑:织梦吧 时间:2010-08-23点击:

织梦的默认标签中的channel标签是无法嵌套输出子栏目信息的,而且织梦默认标签也不支持嵌套输出,下面是一位高手实现的嵌套栏目输出的channel标签增强版本,遗憾的是这一版删除了标准版的一些不常用到的属性。
下面是代码:
<?php
function lib_channel(&$ctag,&$refObj)
{
    global $_sys_globals,$envs,$dsql;
    $attlist = "typeid|0,reid|0,row|100,col|1,type|son,currentstyle|";
    FillAttsDefault($ctag->CAttribute->Items,$attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $innertext = $ctag->GetInnerText();
    if(empty($typeid) && $envs['typeid']!=0)
    {
        $typeid = $envs['typeid'];
        $reid = $envs['reid'];
    }else{
        $reid=0;
    }

    if($type==''||$type=='sun') $type="son";
    if($innertext=='') $innertext = GetSysTemplets("channel_list.htm");

    if($reid==0 && $typeid>0)
    {
        $dbrow = $dsql->GetOne("Select reid From pptde_arctype where id='$typeid' ");
        if(is_array($dbrow)) $reid = $dbrow['reid'];
    }

    $likeType = '';
    if($type=='top')
    {
        $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
          From pptde_arctype where reid=0 And ishidden<>1 order by sortrank asc limit 0,$row";
    }
    else if($type=="son")
    {
        //if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid'];
        if($typeid==0) {
            return '';
        }
        $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
          From pptde_arctype where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row";
    }
    else if($type=="self")
    {
        if($reid==0) {
            return '';
        }
        $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
            From `pptde_arctype` where reid='$reid' And ishidden<>1 order by sortrank asc limit 0,$row";
    }
    //And id<>'$typeid'
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace("field","[","]");
    $dtp2->LoadSource($innertext);
    $dsql2 = clone $dsql;
    $dsql->SetQuery($sql);
    $dsql->Execute();

    $line = $row;
    $GLOBALS['autoindex'] = 0;
    for($i=0;$i < $line;$i++)
    {
        if($col>1) $likeType .= "<dl>\r\n";
        for($j=0;$j<$col;$j++)
        {
            if($col>1) $likeType .= "<dd>\r\n";
            if($row=$dsql->GetArray())
            {
                if($type=='self' && $row['id']==$typeid) //处理同级栏目中,当前栏目的样式

About D8

  • ©2014 织梦吧(d8) DedeCMS学习交流平台
  • 唯一网址 www.DedeCMS8.com 网站地图
  • 联系我们 1170734538@qq.com ,  QQ