帝国CMS灵动标签调用顶级栏目及循环子栏目-带样式——用于首页导航不错
思良:用于简单的2级导航不错
帝国CMS后台自带的导航标签模板调出来的导航没有子栏目,且不带样式,可改用灵动标签实现顶级栏目循环并当前栏目高亮,还可以调出当前栏目下的子栏目,可用作导航下拉。
实例代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
[e:loop={ "select classid,classname from {$dbtbpre}enewsclass where bclassid=0 order by myorder,classid asc" ,0,24,0}] <?php $classurl =sys_ReturnBqClassname( $bqr ,9); //取得栏目地址 $style = "" ; if ( $GLOBALS [navclassid]) { $fcr = explode ( '|' , $class_r [ $GLOBALS [navclassid]][featherclass]); $topbclassid = $fcr [1]? $fcr [1]: $GLOBALS [navclassid]; //取得当前栏目的一级栏目ID if ( $bqr [classid]== $topbclassid ) { $style = "current-menu-item" ; } } ?> <li class = "<?=$style?>" ><a href= "<?=$classurl?>" ><?= $bqr [classname]?></a> <ul><li class = 'litop' ></li> <?php //取得栏目下的子栏目 $newsclass = $empire ->query( "select classid,classname from " . $dbtbpre . "enewsclass where bclassid=" . $bqr [classid]. " order by myorder,classid asc limit 11" ); while ( $classr = $empire ->fetch( $newsclass )) { $classrurl =sys_ReturnBqClassname( $classr ,9); //取得子栏目地址 ?> <li><a href= "<?=$classrurl?>" ><?= $classr [classname]?></a></li> <?php } ?> </ul> </li> [/e:loop] |
另可调出栏目简介、栏目缩略图
1 2 3 4 5 |
[e:loop={ "select classid,classname,classimg,intro from {$dbtbpre}enewsclass where bclassid=0 order by myorder,classid asc" ,0,24,0}] <?= $bqr [classimg]?> //栏目缩略图 <?= $bqr [intro]?> //栏目简介 [/e:loop] |
思良:指定ID的二级导航
[e:loop={"select classid,classname from {$dbtbpre}enewsclass where bclassid=243 and classid!=261 order by myorder,classid asc",0,24,0}]
<?php
$classurl=sys_ReturnBqClassname($bqr,9);//取得栏目地址
$style="";
if($GLOBALS[navclassid])
{
$fcr=explode('|',$class_r[$GLOBALS[navclassid]][featherclass]);
$topbclassid=$fcr[1]?$fcr[1]:$GLOBALS[navclassid];//取得当前栏目的一级栏目ID
if($bqr[classid]==$topbclassid)
{
$style="current-menu-item";
}
}
?>
<li ><span><a href="<?=$classurl?>" style="font-size:14px; line-height:55px;"><?=$bqr[classname]?></a>
<ul>
<?php
//取得栏目下的子栏目
$newsclass=$empire->query("select classid,classname from ".$dbtbpre."enewsclass where bclassid=".$bqr[classid]." order by myorder,classid asc limit 11");
while($classr=$empire->fetch($newsclass))
{
$classrurl=sys_ReturnBqClassname($classr,9); //取得子栏目地址
?>
<li><a href="<?=$classrurl?>" style="font-size:13px;"><?=$classr[classname]?></a></li>
<?php
}
?>
</ul>
</span></li>
[/e:loop]
原文:http://www.xkmov.net/jiaocheng/empirecms/2014-12-20/18.html