内存溢出 jb51.cc 关于Dedecms实现嵌套获取栏目及其子栏目列表的问题,在论坛找到了以前版本的修改方法,用在5.5版本上发现不能用,于是修改了一下,现在分享给大家。请看实例代码:
修改文件:include aglib目录下的channel.lib.PHP,请将以下代码全部复制替换上述文件。
以下为引用的内容: <?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,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,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提示(用于二级菜单)本教程由网提供,更多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'],false); if($row['sonIDs']=='') $row['rel'] = ''; else $row['rel'] = " rel='dropmenu{$row['ID']}'"; } //处理同级栏目中,当前栏目的样式 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,$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,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,$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,$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; } ?> |
以上是内存溢出为你收集整理的DEDECMS v5.5实现嵌套获取栏目及其子栏目列表全部内容,希望文章能够帮你解决DEDECMS v5.5实现嵌套获取栏目及其子栏目列表所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)