国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > 織夢DEDE > 正文

織夢CMS 動態導航下拉菜單的代碼實例

2024-07-09 22:52:27
字體:
來源:轉載
供稿:網友

動態導航下拉菜單的代碼實例

1、修改include/taglib文件夾中的channel.lib.php文件,替換為如下內容:

  1. <?php
  2. /**
  3. * 動態導航下拉菜單
  4. * Edit www.zuimoban.com
  5. * Date 2015-5-3
  6. */
  7. function lib_channel(&$ctag,&$refObj)
  8. {
  9. global $_sys_globals,$envs,$dsql;
  10. $attlist = "typeid|0,reid|0,row|100,col|1,type|son,currentstyle|";
  11. FillAttsDefault($ctag->CAttribute->Items,$attlist);
  12. extract($ctag->CAttribute->Items, EXTR_SKIP);
  13. $innertext = $ctag->GetInnerText();
  14. if(empty($typeid) && $envs['typeid']!=0)
  15. {
  16. $typeid = $envs['typeid'];
  17. $reid = $envs['reid'];
  18. }else{
  19. $reid=0;
  20. }
  21. if($type==''||$type=='sun') $type="son";
  22. if($innertext=='') $innertext = GetSysTemplets("channel_list.htm");
  23. if($reid==0 && $typeid>0)
  24. {
  25. $dbrow = $dsql->GetOne("Select reid From <a href="mailto:`dede_arctype">`dede_arctype</a>` where id='$typeid' ");
  26. if(is_array($dbrow)) $reid = $dbrow['reid'];
  27. }
  28. $likeType = '';
  29. if($type=='top')
  30. {
  31. $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,description
  32. From <a href="mailto:`dede_arctype">`dede_arctype</a>` where reid=0 And ishidden<>1 order by sortrank asc limit 0,$row";
  33. }
  34. else if($type=="son")
  35. {
  36. //if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid'];
  37. if($typeid==0) {
  38. return '';
  39. }
  40. $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,description
  41. From <a href="mailto:`dede_arctype">`dede_arctype</a>` where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row";
  42. }
  43. else if($type=="self")
  44. {
  45. if($reid==0) {
  46. return '';
  47. }
  48. $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,description
  49. From <a href="mailto:`dede_arctype">`dede_arctype</a>` where reid='$reid' And ishidden<>1 order by sortrank asc limit 0,$row";
  50. }
  51. //And id<>'$typeid'
  52. $dtp2 = new DedeTagParse();
  53. $dtp2->SetNameSpace("field","[","]");
  54. $dtp2->LoadSource($innertext);
  55. $dsql2 = clone $dsql;
  56. $dsql->SetQuery($sql);
  57. $dsql->Execute();
  58. $line = $row;
  59. $GLOBALS['autoindex'] = 0;
  60. for($i=0;$i < $line;$i++)
  61. {
  62. if($col>1) $likeType .= "<dl>/r/n";
  63. for($j=0;$j<$col;$j++)
  64. {
  65. if($col>1) $likeType .= "<dd>/r/n";
  66. if($row=$dsql->GetArray())
  67. {
  68. if($type=='self' && $row['id']==$typeid) //處理同級欄目中,當前欄目的樣式
  69. {
  70. if($currentstyle!='')
  71. {
  72. $linkOkstr = $currentstyle;
  73. $row['typelink'] = GetOneTypeUrlA($row);
  74. $linkOkstr = str_replace("~typelink~",$row['typelink'],$linkOkstr);
  75. $linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);
  76. $likeType .= $linkOkstr;
  77. }
  78. }else
  79. {
  80. $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);
  81. if(is_array($dtp2->CTags))
  82. {
  83. foreach($dtp2->CTags as $tagid=>$ctag){
  84. if(isset($row[$ctag->GetName()]))
  85. {
  86. $dtp2->Assign($tagid,$row[$ctag->GetName()]);
  87. }
  88. elseif (preg_match('/^sonchannel[0-9]*$/',$ctag->GetName()))
  89. {
  90. $dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql2));
  91. }
  92. }
  93. }
  94. $likeType .= $dtp2->GetResult();
  95. }
  96. }
  97. if($col>1) $likeType .= "</dd>/r/n";
  98. $GLOBALS['autoindex']++;
  99. }//Loop Col
  100. if($col>1)
  101. {
  102. $i += $col - 1;
  103. $likeType .= " </dl>/r/n";
  104. }
  105. }//Loop for $i
  106. reset($dsql2);
  107. $dsql->FreeResult();
  108. return $likeType;
  109. }
  110. function lib_channel_son($ctag,$typeid = 0,$dsql2)
  111. {
  112. $attlist = "row|100,col|1,currentstyle|";
  113. FillAttsDefault($ctag->CAttribute->Items,$attlist);
  114. extract($ctag->CAttribute->Items, EXTR_SKIP);
  115. $innertext = $ctag->GetInnerText();
  116. $dsql3 = clone $dsql2;
  117. $likeType = '';
  118. //if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid'];
  119. if($typeid==0) {
  120. return '';
  121. }
  122. $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,description
  123. From <a href="mailto:`dede_arctype">`dede_arctype</a>` where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row";
  124. //And id<>'$typeid'
  125. $dtp2 = new DedeTagParse();
  126. $dtp2->SetNameSpace("field","[","]");
  127. $dtp2->LoadSource($innertext);
  128. $dsql2->SetQuery($sql);
  129. $dsql2->Execute();
  130. $line = $row;
  131. for($i=0;$i < $line;$i++)
  132. {
  133. if($col>1) $likeType .= "<dl>/r/n";
  134. for($j=0;$j<$col;$j++)
  135. {
  136. if($col>1) $likeType .= "<dd>/r/n";
  137. if($row=$dsql2->GetArray())
  138. {
  139. $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);
  140. if(is_array($dtp2->CTags))
  141. {
  142. foreach($dtp2->CTags as $tagid=>$ctag){
  143. if(isset($row[$ctag->GetName()]))
  144. {
  145. $dtp2->Assign($tagid,$row[$ctag->GetName()]);
  146. }
  147. elseif (preg_match('/^sonchannel[0-9]*$/',$ctag->GetName()))
  148. {
  149. $dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql3));
  150. }
  151. }
  152. }
  153. $likeType .= $dtp2->GetResult();
  154. }
  155. if($col>1) $likeType .= "</dd>/r/n";
  156. }//Loop Col
  157. if($col>1)
  158. {
  159. $i += $col - 1;
  160. $likeType .= " </dl>/r/n";
  161. }
  162. }//Loop for $i
  163. reset($dsql3);
  164. $dsql2->FreeResult();
  165. return $likeType;
  166. }
  167. ?>
  168. 2、調用示例
  169. {dede:channel typeid='1'}
  170. <li>
  171. <a class="" href="[field:typeurl/]" title="">[field:typename/]
  172. <img src="***.gif" /></a>
  173. <div class="sub">
  174. <ul>
  175. [field:sonchannel0]<li><a href="[field:typeurl/]">[field:typename/]</a></li>[/field:sonchannel0]
  176. </ul>
  177. </div>
  178. </li>
  179. {/dede:channel}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 射洪县| 时尚| 通海县| 张家口市| 瑞丽市| 睢宁县| 炎陵县| 甘肃省| 高碑店市| 家居| 临西县| 东丰县| 沧州市| 棋牌| 盐山县| 岳池县| 桑植县| 保康县| 临邑县| 柳林县| 六盘水市| 龙山县| 固阳县| 遂平县| 阿城市| 汉源县| 东乡族自治县| 涞水县| 顺昌县| 聂荣县| 抚松县| 建湖县| 高州市| 安岳县| 尼勒克县| 招远市| 乌兰浩特市| 莲花县| 乳源| 察隅县| 吴川市|