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

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

发布时间:2020-05-24 08:13:36 所属栏目:CMS系统 来源:互联网
导读:一、修改文件:includetaglib目录下的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|; Fi

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

functionlib_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("SelectreidFromdede_arctypewhereid='$typeid'");
is_array($dbrow))$dbrow['reid'];
}
$likeType='';
$type=='top')
{
$sql="Selectid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
Fromdede_arctypewherereid=0Andishidden<>1orderbysortrankasclimit0,128); line-height: 1.5 !important;">$row";
}
else$type=="son")
{
//if($_sys_globals['typeid']>0)$typeid=$_sys_globals['typeid'];
$typeid==0){
return'';
}
Fromdede_arctypewherereid='$typeid'Andishidden<>1orderbysortrankasclimit0,128); line-height: 1.5 !important;">$type=="self")
{
$reid==0){
From`dede_arctype`wherereid='$reid'Andishidden<>1orderbysortrankasclimit0,0); line-height: 1.5 !important;">Andid<>'$typeid'
$needRel=false;
$dtp2=newDedeTagParse();
$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->CTagsas$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']++;
}LoopCol
$col>1)
{
$i+=$col-1;
$likeType.="
}
}Loopfor$i
reset($dsql2);
$dsql->FreeResult();
$likeType;
}
functionlib_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:channeltype='son'typeid='22'}
[field:typename/]
[field:sonchannel0]
li> [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+数字] 作为标签名是为了防止嵌套的时候无法正确解析标签)

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

(编辑:安卓应用网)

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

    推荐文章
      热点阅读