国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > CMS > 織夢(mèng)DEDE > 正文

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

2024-07-12 09:06:41
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

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

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

 

以下為引用的內(nèi)容:<?phpfunction 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提示(用于二級(jí)菜單)本教程由烈火網(wǎng)提供,更多http://www.CUOxin.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>/r/n";        for($j=0;$j<$col;$j++)        {            if($col>1) $likeType .= "<dd>/r/n";            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']}'";                }                //處理同級(jí)欄目中,當(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>/r/n";            $GLOBALS['autoindex']++;        }//Loop Col        if($col>1)        {            $i += $col - 1;            $likeType .= "    </dl>/r/n";        }    }//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>/r/n";        for($j=0;$j<$col;$j++)        {            if($col>1) $likeType .= "<dd>/r/n";            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>/r/n";        }//Loop Col        if($col>1)        {            $i += $col - 1;            $likeType .= "    </dl>/r/n";        }    }//Loop for $i    reset($dsql3);    $dsql2->FreeResult();    return $likeType;}?>

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 奇台县| 清水县| 绍兴市| 沿河| 自贡市| 吉隆县| 庆云县| 西畴县| 武乡县| 即墨市| 江永县| 宜章县| 台山市| 南涧| 汉沽区| 体育| 泸溪县| 颍上县| 图木舒克市| 宁津县| 澎湖县| 黄龙县| 新野县| 涞水县| 苏州市| 凌云县| 门头沟区| 九龙城区| 巴东县| 利津县| 贵阳市| 广平县| 寻甸| SHOW| 呼图壁县| 紫云| 嫩江县| 龙里县| 巴彦淖尔市| 杂多县| 定州市|