多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內(nèi)最全I(xiàn)T社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > php開源 > DedeCMS > DEDECMS v5.5實現(xiàn)嵌套獲取欄目及其子欄目列表

DEDECMS v5.5實現(xiàn)嵌套獲取欄目及其子欄目列表

來源:程序員人生   發(fā)布時間:2014-05-07 21:24:06 閱讀次數(shù):2688次

  網(wǎng)(LieHuo.Net)教程 關(guān)于DEDECMS實現(xiàn)嵌套獲取欄目及其子欄目列表的問題,在論壇找到了以前版本的修改方法,用在5.5版本上發(fā)現(xiàn)不能用,于是修改了一下,現(xiàn)在分享給大家。請看實例代碼:

  修改文件:include aglib目錄下的channel.lib.php,請將以下代碼全部復(fù)制替換上述文件。

以下為引用的內(nèi)容:
<?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();
        $cacheid = trim($cacheid);
    if($cacheid !='') {
        $likeType = GetCacheBlock($cacheid);
        if($likeType != '') return $likeType;
    }

    $reid = 0;
    $topid = 0;
    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 dede_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 dede_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 dede_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 `dede_arctype` where reid='$reid' And ishidden<>1 order by sortrank asc limit 0,$row";
    }
    //And id<>'$typeid'
    $needRel = false;
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace("field","[","]");
    $dtp2->LoadSource($innertext);
    $dsql2 = clone $dsql;
    $dsql->SetQuery($sql);
    $dsql->Execute();

    $line = $row;
        //檢查是否有子欄目,并返回rel提示(用于二級菜單)本教程由網(wǎng)提供,更多http://www.veryhuo.com/
    if(ereg(':rel', $innertext)) $needRel = true;
    
    if(empty($sql)) return '';
    $dsql->SetQuery($sql);
    $dsql->Execute();
    
    $totalRow = $dsql->GetTotalRow();
    $GLOBALS['autoindex'] = 0;
    for($i=0;$i < $line;$i++)
    {
        if($col>1) $likeType .= "<dl>";
        for($j=0;$j<$col;$j++)
        {
            if($col>1) $likeType .= "<dd>";
            if($row=$dsql->GetArray())
            {
                            $row['sonids'] = $row['rel'] = '';
                if($needRel)
                {
                    $row['sonids'] = GetSonIds($row['id'], 0, false);
                    if($row['sonids']=='') $row['rel'] = '';
                    else $row['rel'] = " rel='dropmenu{$row['id']}'";
                }
                //處理同級欄目中,當(dāng)前欄目的樣式
                if( ($row['id']==$typeid || ($topid==$row['id'] && $type=='top') ) && $currentstyle!='' )
                {
                    if($currentstyle!='')
                    {
                    $linkOkstr = $currentstyle;
                    $row['typelink'] = GetOneTypeUrlA($row);
                    $linkOkstr = str_replace("~rel~",$row['rel'],$linkOkstr);
                    $linkOkstr = str_replace("~id~",$row['id'],$linkOkstr);
                    $linkOkstr = str_replace("~typelink~",$row['typelink'],$linkOkstr);
                    $linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);
                    $likeType .= $linkOkstr;
                    }
                }else
                {
                    $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);
                    if(is_array($dtp2->CTags))
                    {
                        foreach($dtp2->CTags as $tagid=>$ctag){
                            if(isset($row[$ctag->GetName()]))
                            {
                                $dtp2->Assign($tagid,$row[$ctag->GetName()]);
                            }
                            elseif (preg_match('/^sonchannel[0-9]*$/',$ctag->GetName()))
                            {
                                $dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql2));
                            }
                        }
                    }
                    $likeType .= $dtp2->GetResult();
                }
            }
            if($col>1) $likeType .= "</dd>";
            $GLOBALS['autoindex']++;
        }//Loop Col
        if($col>1)
        {
            $i += $col - 1;
            $likeType .= "    </dl>";
        }
    }//Loop for $i
    reset($dsql2);
    $dsql->FreeResult();
    return $likeType;
}
function lib_channel_son($ctag,$typeid = 0,$dsql2)
{
    $attlist = "row|100,col|1,currentstyle|";
    FillAttsDefault($ctag->CAttribute->Items,$attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $innertext = $ctag->GetInnerText();
    $dsql3 = clone $dsql2;
    $likeType = '';

    //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 dede_arctype where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row";
    //And id<>'$typeid'
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace("field","[","]");
    $dtp2->LoadSource($innertext);
    $dsql2->SetQuery($sql);
    $dsql2->Execute();
    $line = $row;

    for($i=0;$i < $line;$i++)
    {
        if($col>1) $likeType .= "<dl>";
        for($j=0;$j<$col;$j++)
        {
            if($col>1) $likeType .= "<dd>";
            if($row=$dsql2->GetArray())
            {
                $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);
                if(is_array($dtp2->CTags))
                {
                    foreach($dtp2->CTags as $tagid=>$ctag){
                        if(isset($row[$ctag->GetName()]))
                        {
                            $dtp2->Assign($tagid,$row[$ctag->GetName()]);
                        }
                        elseif (preg_match('/^sonchannel[0-9]*$/',$ctag->GetName()))
                        {
                            $dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql3));
                        }
                    }
                }
                $likeType .= $dtp2->GetResult();
            }
            if($col>1) $likeType .= "</dd>";
        }//Loop Col
        if($col>1)
        {
            $i += $col - 1;
            $likeType .= "    </dl>";
        }
    }//Loop for $i
    reset($dsql3);
    $dsql2->FreeResult();
    return $likeType;
}
?>

生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 欧美激情福利 | 春色精品视频在线播放 | 一区二区三区免费视频播放器 | 欧美一区永久视频免费观看 | 欧美精品一区二区三区视频 | freefromevideos性欧美 | 天天天狠天天透天天制色 | 国产成人福利 | 性欧美video另类hd | 一二三四日本手机高清视频 | 免费成年人在线视频 | 毛片免费观看视频 | 91视频影院 | 福利片国产 | 视频一区二区在线 | 国产小情侣激情小视频免费看 | www.av在线.com | 黄色网址免费看 | 黄h视频在线观看视频 | 手机看片日韩日韩 | 国产日韩精品欧美一区 | 久久一本精品久久精品66 | 色在线网站 | 亚洲不卡在线视频 | 中文字幕一区二区三区在线播放 | 视频一区二区三区在线 | www视频在线免费观看 | 91视频www| 亚欧美综合 | 成人精品视频在线观看播放 | 日本成人在线网址 | 成人偷拍自拍 | 欧美视频xxx | 久久综合国产 | 2022久久国产精品免费热麻豆 | 成人欧美一区二区三区视频xxx | 香蕉蕉亚亚洲aav综合 | 国内成人自拍 | 日韩欧美伊人久久大香线蕉 | 日本免费中文字幕在线看 | 午夜国产精品久久影院 |