织梦DedeCMS三级四级栏目无限级调用

织梦DedeCMS三级四级栏目无限级调用,第1张

概述这篇文章主要介绍了织梦dede调用四级栏目的实现方法的相关资料,觉得挺不错的,现在分享给大家,也给大家做个参考。

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。内存溢出小编现在分享给大家,也给大家做个参考。

这篇文章主要介绍了织梦 dede 调用四级栏目的实现方法的相关资料,觉得挺不错的,现在分享给大家,也给大家做个参考,估计做网站的朋友很多都是用织梦,小编也有自己的一些心得体会,接下来就分享一下轻松调用织梦的四级栏目,通俗易懂的说明,需要的朋友可以参考借鉴。织梦调用四级或者无限级子栏目,首先需要修改文件:includetaglibchannel.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提示(用于二级菜单)

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>rn";

for($j=0;$j<$col;$j++)

{

if($col>1) $likeType .= "<dd>rn";

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>rn";

$GLOBALS['autoindex']++;

}//Loop Col

if($col>1)

{

$i += $col - 1;

$likeType .= " </dl>rn";

}

}//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>rn";

for($j=0;$j<$col;$j++)

{

if($col>1) $likeType .= "<dd>rn";

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,$dsql3));

}

}

}

$likeType .= $dtp2->GetResult();

}

if($col>1) $likeType .= "</dd>rn";

}//Loop Col

if($col>1)

{

$i += $col - 1;

$likeType .= " </dl>rn";

}

}//Loop for $i

reset($dsql3);

$dsql2->FreeResult();

return $likeType;

}

?>

模板调用:

{dede:channel type='son' typeID='3'}

[fIEld:typename/]

<ul>

[fIEld:sonchannel0]

<li><a href="[fIEld:typelink/]">[fIEld:typename/]</a></li>

[fIEld:sonchannel1]

<li><a href="[fIEld:typelink/]">---[fIEld:typename/]</a></li>

[fIEld:sonchannel2]

<li><a href="[fIEld:typelink/]">===[fIEld:typename/]</a></li>

[fIEld:sonchannel3]

<li><a href="[fIEld:typelink/]">===[fIEld:typename/]</a></li>

[/fIEld:sonchannel3]

[/fIEld:sonchannel2]

[/fIEld:sonchannel1]

[/fIEld:sonchannel0]

</ul>

{/dede:channel}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持内存溢出。

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的织梦DedeCMS三级四级栏目无限级调用全部内容,希望文章能够帮你解决织梦DedeCMS三级四级栏目无限级调用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/1027189.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-23
下一篇2022-05-23

发表评论

登录后才能评论

评论列表(0条)

    保存