帝国导航调用高级php代码

导航代码:

<li class="<?=$GLOBALS[navclassid]?"":"current-menu-item"?>"><a href="[!--news.url--]">首页</a></li>
<?php
$sql=$empire->query("select classid,sonclass,classname,islast,islist from {$dbtbpre}enewsclass where bclassid=0 and showclass=0 order by myorder,myorder asc");
while($s=$empire->fetch($sql)){
$classurl=sys_ReturnBqClassname($s,9); 
$tclass="";
$fr=explode('|',$class_r[$GLOBALS[navclassid]][featherclass]);
$topbclassid=$fr[1]?$fr[1]:$GLOBALS[navclassid];
if($topbclassid==$s[classid]){
$tclass='current-menu-item';
}
echo '<li class="'.$tclass.'" ><a href="'.$classurl.'">'.$s[classname].'</a>';
if($s[islast]==0){
$sql2=$empire->query("select classid,classname from {$dbtbpre}enewsclass where bclassid=$s[classid] and showclass=0 order by myorder,myorder asc");
$str="";
while($s2=$empire->fetch($sql2)){
$classurl2=sys_ReturnBqClassname($s2,9); 
$str.='<li><a href="'.$classurl2.'">'.$s2[classname].'</a></li>';
}
echo '<ul class="sub-menu">'.$str.'</ul>';
}
echo '</li>';
}
?>

一级栏目 二级栏目同时调用

<li class="<?= ($GLOBALS['navclassid'] ? '' : 'current-menu-item') ?>"><a href="[!--news.url--]">首页</a></li>
<?php
// 查询一级菜单
$sql = $empire->query("select classid, sonclass, classname, islast, islist from {$dbtbpre}enewsclass where bclassid=0 and showclass=0 order by myorder asc");
while ($primaryMenu = $empire->fetch($sql)) {
    $classUrl = sys_ReturnBqClassname($primaryMenu, 9); 
    $topClass = '';
    $featherClass = explode('|', $class_r[$GLOBALS['navclassid']]['featherclass']);
    $topbclassid = $featherClass[1] ? $featherClass[1] : $GLOBALS['navclassid'];
    
    // 判断是否为当前菜单
    if ($topbclassid == $primaryMenu['classid']) {
        $topClass = 'current-menu-item';
    }
    
?>
<li class="<?=$topClass?>"><a href="<?=$classUrl?>"><?=$primaryMenu['classname']?></a>

<?php if ($primaryMenu['islast'] == 0) {?>
<ul class="sub-menu">
<?
	$sql2 = $empire->query("select classid, classname from {$dbtbpre}enewsclass where bclassid={$primaryMenu['classid']} and showclass=0 order by myorder asc");
	$subMenuStr = "";
	while ($secondaryMenu = $empire->fetch($sql2)) {
		$classUrl2 = sys_ReturnBqClassname($secondaryMenu, 9);
		?>
		<li><a href="<?=$classUrl2?>"><?=$secondaryMenu['classname']?></a></li>
		<?
	}
?>
</ul>
<?}?>

</li>
<?}?>

只调用一级栏目:

<?php
// 查询一级菜单
$sql = $empire->query("select classid, sonclass, classname, islast, islist from {$dbtbpre}enewsclass where bclassid=0 and showclass=0 order by myorder asc");
while ($primaryMenu = $empire->fetch($sql)) {
    $classUrl = sys_ReturnBqClassname($primaryMenu, 9); 
    $topClass = '';
    $featherClass = explode('|', $class_r[$GLOBALS['navclassid']]['featherclass']);
    $topbclassid = $featherClass[1] ? $featherClass[1] : $GLOBALS['navclassid'];
    
    // 判断是否为当前菜单
    if ($topbclassid == $primaryMenu['classid']) {
        $topClass = 'current-menu-item';
    }
    
?>
<li class="navbar-item <?=$topClass?>"><a href="<?=$classUrl?>"><?=$primaryMenu['classname']?></a></li>
<?}?>

 

© 版权声明
THE END
喜欢就支持一下吧
点赞12
相关推荐
评论 抢沙发

请登录后发表评论

    暂无评论内容