织梦dede调用四级栏目

大家快瞧那结冰的湖水,春风一吹冰都融化了,河里的小鱼都游出海面,在湖水中自由的游来游去,多可爱的小鱼啊!多么欢快的小鱼啊!真是让人深深的为它那可爱的摸样着迷。春风一吹过那枯黄的小草身边时,小草突然边了摸样,它从原来的枯黄变成了嫩绿,慢慢地小草从嫩绿变成了鲜绿渐渐地越变越绿,绿的让人难以相信那是小草。啊!小草我为你的样子感到是个奇迹。
织梦调用四级子栏目,首先需要修改文件:\include\taglib\channel.lib.php,请将以下代码全部复制替换上述文件:
001	<?php
002	function lib_channel(&$ctag,&$refObj)
003	{
004	global $_sys_globals,$envs,$dsql;
005	$attlist = "typeid|0,reid|0,row|100,col|1,type|son,currentstyle|";
006	FillAttsDefault($ctag->CAttribute->Items,$attlist);
007	extract($ctag->CAttribute->Items, EXTR_SKIP);
008	$innertext = $ctag->GetInnerText();
009	$cacheid = trim($cacheid);
010	if($cacheid !='') {
011	$likeType = GetCacheBlock($cacheid);
012	if($likeType != '') return $likeType;
013	}
014	 
015	$reid = 0;
016	$topid = 0;
017	if(empty($typeid) && $envs['typeid']!=0)
018	{
019	$typeid = $envs['typeid'];
020	$reid = $envs['reid'];
021	}else{
022	$reid=0;
023	}
024	if($type==''||$type=='sun') $type="son";
025	if($innertext=='') $innertext = GetSysTemplets("channel_list.htm");
026	if($reid==0 && $typeid>0)
027	{
028	$dbrow = $dsql->GetOne("Select reid From dede_arctype where id='$typeid' ");
029	if(is_array($dbrow)) $reid = $dbrow['reid'];
030	}
031	$likeType = '';
032	if($type=='top')
033	{
034	$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
035	From dede_arctype where reid=0 And ishidden<>1 order by sortrank asc limit 0,$row";
036	}
037	else if($type=="son")
038	{
039	//if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid'];
040	if($typeid==0) {
041	return '';
042	}
043	$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
044	From dede_arctype where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row";
045	}
046	else if($type=="self")
047	{
048	if($reid==0) {
049	return '';
050	}
051	$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
052	From `dede_arctype` where reid='$reid' And ishidden<>1 order by sortrank asc limit 0,$row";
053	}
054	//And id<>'$typeid'
055	$needRel = false;
056	$dtp2 = new DedeTagParse();
057	$dtp2->SetNameSpace("field","[","]");
058	$dtp2->LoadSource($innertext);
059	$dsql2 = clone $dsql;
060	$dsql->SetQuery($sql);
061	$dsql->Execute();
062	$line = $row;
063	//检查是否有子栏目,并返回rel提示(用于二级菜单)
064	if(ereg(':rel', $innertext)) $needRel = true;
065	 
066	if(empty($sql)) return '';
067	$dsql->SetQuery($sql);
068	$dsql->Execute();
069	 
070	$totalRow = $dsql->GetTotalRow();
071	$GLOBALS['autoindex'] = 0;
072	for($i=0;$i < $line;$i++)
073	{
074	if($col>1) $likeType .= "<dl>\r\n";
075	for($j=0;$j<$col;$j++)
076	{
077	if($col>1) $likeType .= "<dd>\r\n";
078	if($row=$dsql->GetArray())
079	{
080	$row['sonids'] = $row['rel'] = '';
081	if($needRel)
082	{
083	$row['sonids'] = GetSonIds($row['id'], 0, false);
084	if($row['sonids']=='') $row['rel'] = '';
085	else $row['rel'] = " rel='dropmenu{$row['id']}'";
086	}
087	//处理同级栏目中,当前栏目的样式
088	if( ($row['id']==$typeid || ($topid==$row['id'] && $type=='top') ) && $currentstyle!='' )
089	{
090	if($currentstyle!='')
091	{
092	$linkOkstr = $currentstyle;
093	$row['typelink'] = GetOneTypeUrlA($row);
094	$linkOkstr = str_replace("~rel~",$row['rel'],$linkOkstr);
095	$linkOkstr = str_replace("~id~",$row['id'],$linkOkstr);
096	$linkOkstr = str_replace("~typelink~",$row['typelink'],$linkOkstr);
097	$linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);
098	$likeType .= $linkOkstr;
099	}
100	}else
101	{
102	$row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);
103	if(is_array($dtp2->CTags))
104	{
105	foreach($dtp2->CTags as $tagid=>$ctag){
106	if(isset($row[$ctag->GetName()]))
107	{
108	$dtp2->Assign($tagid,$row[$ctag->GetName()]);
109	}
110	elseif (preg_match('/^sonchannel[0-9]*$/',$ctag->GetName()))
111	{
112	$dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql2));
113	}
114	}
115	}
116	$likeType .= $dtp2->GetResult();
117	}
118	}
119	if($col>1) $likeType .= "</dd>\r\n";
120	$GLOBALS['autoindex']++;
121	}//Loop Col
122	if($col>1)
123	{
124	$i += $col - 1;
125	$likeType .= " </dl>\r\n";
126	}
127	}//Loop for $i
128	reset($dsql2);
129	$dsql->FreeResult();
130	return $likeType;
131	}
132	function lib_channel_son($ctag,$typeid = 0,$dsql2)
133	{
134	$attlist = "row|100,col|1,currentstyle|";
135	FillAttsDefault($ctag->CAttribute->Items,$attlist);
136	extract($ctag->CAttribute->Items, EXTR_SKIP);
137	$innertext = $ctag->GetInnerText();
138	$dsql3 = clone $dsql2;
139	$likeType = '';
140	//if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid'];
141	if($typeid==0) {
142	return '';
143	}
144	$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
145	From dede_arctype where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row";
146	//And id<>'$typeid'
147	$dtp2 = new DedeTagParse();
148	$dtp2->SetNameSpace("field","[","]");
149	$dtp2->LoadSource($innertext);
150	$dsql2->SetQuery($sql);
151	$dsql2->Execute();
152	$line = $row;
153	for($i=0;$i < $line;$i++)
154	{
155	if($col>1) $likeType .= "<dl>\r\n";
156	for($j=0;$j<$col;$j++)
157	{
158	if($col>1) $likeType .= "<dd>\r\n";
159	if($row=$dsql2->GetArray())
160	{
161	$row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);
162	if(is_array($dtp2->CTags))
163	{
164	foreach($dtp2->CTags as $tagid=>$ctag){
165	if(isset($row[$ctag->GetName()]))
166	{
167	$dtp2->Assign($tagid,$row[$ctag->GetName()]);
168	}
169	elseif (preg_match('/^sonchannel[0-9]*$/',$ctag->GetName()))
170	{
171	$dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql3));
172	}
173	}
174	}
175	$likeType .= $dtp2->GetResult();
176	}
177	if($col>1) $likeType .= "</dd>\r\n";
178	}//Loop Col
179	if($col>1)
180	{
181	$i += $col - 1;
182	$likeType .= " </dl>\r\n";
183	}
184	}//Loop for $i
185	reset($dsql3);
186	$dsql2->FreeResult();
187	return $likeType;
188	}
189	?>
2、在模板中调用实例:
01	{dede:channel type='son' typeid='3'}
02	[field:typename/]
03	<ul>
04	[field:sonchannel0]
05	<li><a rel="nofollow noopener noreferrer" href="[field:typelink/]">[field:typename/]</a></li>
06	[field:sonchannel1]
07	<li><a rel="nofollow noopener noreferrer" href="[field:typelink/]">---[field:typename/]</a></li>
08	[field:sonchannel2]
09	<li><a rel="nofollow noopener noreferrer" href="[field:typelink/]">===[field:typename/]</a></li>
10	[field:sonchannel3]
11	<li><a rel="nofollow noopener noreferrer" href="[field:typelink/]">===[field:typename/]</a></li>
12	[/field:sonchannel3]
13	[/field:sonchannel2]
14	[/field:sonchannel1]
15	[/field:sonchannel0]
16	</ul>
17	{/dede:channel}

到此这篇关于织梦dede调用四级栏目就介绍到这了。逆境,是上帝帮你淘汰竞争者的地方;要知道,你不好受,别人也不好受,你坚持不下去了,别人也一样,千万不要告诉别人你坚持不住了,那只能让别人获得坚持的信心,让竞争者看着你的面孔,失去信心,退出。胜利,属于那些有耐心的人!更多相关织梦dede调用四级栏目内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!

您可能有感兴趣的文章
织梦dedecms如何调用四级栏目

织梦模板dedeCMS调用四级栏目的方法

织梦如何调用四级栏目

dedecms织梦调用三级四级无限级栏目好代码教程

织梦dedecms三级、四级栏目下调用上级栏目名称