加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > CMS系统 > Dedecms > 正文

DEDE5.6,DEDE5.7实现同时调用一级、二级、三级栏目

发布时间:2020-12-14 05:27:45 所属栏目:Dedecms 来源:网络整理
导读:一、修改文件:includetaglib目录下的channel.lib.php,请将以下代码全部复制替换上述文件 function ?lib_channel( $ctag , $refObj ) { ???? global ? $_sys_globals , $envs ,128); line-height: 1.5 !important;">$dsql ; ???? $attlist ?=?"typeid|0,r

一、修改文件:includetaglib目录下的channel.lib.php,请将以下代码全部复制替换上述文件

function?lib_channel(&$ctag,&$refObj)
{
????global?$_sys_globals,$envs,128); line-height: 1.5 !important;">$dsql;
????$attlist?=?"typeid|0,reid|0,row|100,col|1,type|son,currentstyle|";
????FillAttsDefault($ctag->CAttribute->Items,128); line-height: 1.5 !important;">$attlist);
????extract($innertext?=?$ctag->GetInnerText();
????????$cacheid?=?trim($cacheid);
????if($cacheid?!='')?{
????????$likeType?=?GetCacheBlock($cacheid);
????????$likeType?!=?'')?return?$likeType;
????}

????$reid?=?0;
????$topid?=?0;
????if(empty($typeid)?&&?$envs['typeid']!=0)
????{
????????$typeid?=?$envs['typeid'];
????????$reid?=?$envs['reid'];
????}else{
????????$reid=0;
????}
????$type==''||$type=='sun')?$type="son";
????$innertext=='')?$innertext?=?GetSysTemplets("channel_list.htm");
????$reid==0?&&?$typeid>0)
????{
????????$dbrow?=?$dsql->GetOne("Select?reid?From?dede_arctype?where?id='$typeid'?");
????????is_array($dbrow))?$dbrow['reid'];
????}
????$likeType?=?'';
????$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,128); line-height: 1.5 !important;">$row";
????}
????else?$type=="son")
????{
????????//if($_sys_globals['typeid']>0)?$typeid?=?$_sys_globals['typeid'];
????????$typeid==0)?{
????????????return?'';
????????}
????????$typeid'?And?ishidden<>1?order?by?sortrank?asc?limit?0,128); line-height: 1.5 !important;">$type=="self")
????{
????????$reid==0)?{
????????????$reid'?And?ishidden<>1?order?by?sortrank?asc?limit?0,0); line-height: 1.5 !important;">And?id<>'$typeid'
????$needRel?=?false;
????$dtp2?=?new?DedeTagParse();
????$dtp2->SetNameSpace("field","[","]");
????$dtp2->LoadSource($innertext);
????$dsql2?=?clone?$dsql->SetQuery($sql);
????$dsql->Execute();
????$line?=?$row;
????????检查是否有子栏目,并返回rel提示(用于二级菜单)
????ereg(':rel',?$innertext))?true;
???
????$sql))?return?'';
????$dsql->Execute();
???
????$totalRow?=?$dsql->GetTotalRow();
????$GLOBALS['autoindex']?=?0;
????for($i=0;$i?$line;$i++)
????{
????????$col>1)?$likeType?.=?" ????????$j=0;$j<$col;$j++)
????????{
????????????$likeType?.=?" ????????????$row=$dsql->GetArray())
????????????{
????????????????????????????$row['sonids']?=?$row['rel']?=?'';
????????????????$needRel)
????????????????{
????????????????????$row['sonids']?=?GetSonIds($row['id'],?0,?false);
????????????????????$row['sonids']=='')?$row['rel']?=?'';
????????????????????else?$row['rel']?=?"?rel='dropmenu{$row['id']}'";
????????????????}
????????????????处理同级栏目中,当前栏目的样式
????????????????if(?($row['id']==$typeid?||?($topid==$row['id']?&&?$type=='top')?)?&&?$currentstyle!=''?)
????????????????{
????????????????????$currentstyle!='')
????????????????????{
????????????????????$linkOkstr?=?$currentstyle;
????????????????????$row['typelink']?=?GetOneTypeUrlA($row);
????????????????????$linkOkstr?=?str_replace("~rel~",128); line-height: 1.5 !important;">$row['rel'],128); line-height: 1.5 !important;">$linkOkstr);
????????????????????str_replace("~id~",128); line-height: 1.5 !important;">str_replace("~typelink~",128); line-height: 1.5 !important;">$row['typelink'],128); line-height: 1.5 !important;">str_replace("~typename~",128); line-height: 1.5 !important;">$row['typename'],128); line-height: 1.5 !important;">$likeType?.=?$linkOkstr;
????????????????????}
????????????????}else
????????????????{
????????????????????$row['typelink']?=?$row['typeurl']?=?GetOneTypeUrlA($row);
????????????????????$dtp2->CTags))
????????????????????{
????????????????????????foreach($dtp2->CTags?as?$tagid=>$ctag){
????????????????????????????isset($row[$ctag->GetName()]))
????????????????????????????{
????????????????????????????????$dtp2->Assign($tagid,128); line-height: 1.5 !important;">$ctag->GetName()]);
????????????????????????????}
????????????????????????????elseif?(preg_match('/^sonchannel[0-9]*$/',128); line-height: 1.5 !important;">$ctag->GetName()))
????????????????????????????{
????????????????????????????????$dsql2));
????????????????????????????}
????????????????????????}
????????????????????}
????????????????????$dtp2->GetResult();
????????????????}
????????????}
????????????$likeType?.=?"
????????????$GLOBALS['autoindex']++;
????????}Loop?Col
????????$col>1)
????????{
????????????$i?+=?$col?-?1;
????????????$likeType?.=?"????
????????}
????}Loop?for?$i
????reset($dsql2);
????$dsql->FreeResult();
????$likeType;
}
function?lib_channel_son($typeid?=?0,128); line-height: 1.5 !important;">$dsql2)
{
????$attlist?=?"row|100,128); line-height: 1.5 !important;">$ctag->GetInnerText();
????$dsql3?=?$dsql2;
????if($_sys_globals['typeid']>0)?$typeid?=?$_sys_globals['typeid'];
????$typeid==0)?{
????????return?'';
????}
????$row";
????$dsql2->SetQuery($dsql2->Execute();
????$row;
????$dsql2->GetArray())
????????????{
????????????????$row);
????????????????$dtp2->CTags))
????????????????{
????????????????????$ctag){
????????????????????????$ctag->GetName()]))
????????????????????????{
????????????????????????????$ctag->GetName()]);
????????????????????????}
????????????????????????$ctag->GetName()))
????????????????????????{
????????????????????????????$dsql3));
????????????????????????}
????????????????????}
????????????????}
????????????????$dtp2->GetResult();
????????????}
????????????$likeType?.=?" ????????}$dsql3);
????$dsql2->FreeResult();
????$likeType;
}
?>

?

二、在模板调用
实例:

?

{dede:channel?type='son'?typeid='22'}
??????????????[field:typename/]
????????????????????<ul>
????????????????????[field:sonchannel0]
????????????????????li><a?href="http://www.dede58.com/[field:typelink/]">[field:typename/]a>>
?????????????????????????[field:sonchannel1]
????????????????????????="http://www.dede58.com/[field:typelink/]">---[field:typename/]>
?????????????????????????????[field:sonchannel2]
????????????????????????????>===[field:typename/]>
????????????????????????????????[field:sonchannel3]
????????????????????????????????>
?????????????????????????????????[/field:sonchannel3]
?????????????????????????????[/field:sonchannel2]
?????????????????????????[/field:sonchannel1]
????????????????????[/field:sonchannel0]
????????????????????>

?{/dede:channel}

模板调用??? [field:sonchannel0] [/field:sonchannel0] 这个是用来取子栏目用得(使用[sonchannel+数字] 作为标签名是为了防止嵌套的时候无法正确解析标签)

这个的作用就是当你的栏目有很多子栏目 无限分级的时候方便你取子栏目的

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读