帝国cms栏目导航实现,三级、四级、栏目导航

 第一步:
修改e/class/userfun.php文件,这个文件是专门应用用户自定义函数用的,不用担心。

一般您的此文件会是这样的。如果有改动,说明您是高手跟不就不需要解释了吧。
<?php

//—————————用户自定义标签函数文件

?>

修改为

<?php

 

//—————————用户自定义标签函数文件

 

//循环次级栏目函数

 

function user_ListCats($bclassid) {

 

global $empire, $dbtbpre;

 

//        classpath 为地址

 

$sql=$empire->query("select classid, classname, bclassid, islast, classpath, classurl from {$dbtbpre}enewsclass where bclassid=’$bclassid’ and wburl=” order by myorder,classid");

 

//        判断是否有类别记录

 

        $num=$empire->num1($sql);

 

        if ($num == 0 && $bclassid == 0)//无记录

 

        {

 

            echo $GLOBALS[‘notrecordword’];

 

            return "";

 

        }

 

        if ($num == 0)

 

        {

 

            return ”;

 

        }

 

        $i = 1;

 

        while ($r=$empire->fetch($sql))

 

        {

 

            //        如果不是终极栏目,显示其子目录

 

            if(empty($r[islast]))

 

            {

 

                echo ‘<li><a href="/’ . $r[classpath] . ‘">’ . $r[classname] . ‘</a>’."/r/n";

 

                              

 

                                echo ‘</li>’."/r/n";

   echo ‘<ul class="sub2">’."/r/n";

 

                user_ListCats($r[classid], $showMore);

 

                                echo ‘</ul>’."/r/n";

 

            } else {

 

                echo ‘<li><a href="/’ . $r[classpath] . ‘">’ . $r[classname] . ‘</a></li>’."/r/n";

 

            }

 

            $i += 1;

 

        }

 

    }

 

?>

 

 

 

修改完成保存后,上传替换原来的e/class/userfun.php文件。

第二步:进入后台管理
点击。模板–>标签–>管理标签
点击 增加标签 按钮
标签名:写您自己看得懂的
标签符号:myli (当然你也可以自己写喜欢的,一会在调用标签时对应这个就行了)

所属类别:不用改。爱改你就改。
函数名:user_ListCats
一定要写对哦大小写,不可改动,一定要写对。
是否开启标签 选是
然后点提交。

第三步:在你需要调用的地方。加入代码

<div>
<ul>
[myli]0,1[/myli]
</ul>
</div>

好了试试看是不是全都出来了?
关于[myli]0,1[/myli]的两个参数 ,第一个是栏目ID,0为所有栏目,第二个是,是否显示多级子栏目,1为显示。0为只显示一级。

顺便提供给大家一个弹出的无限菜单实例做参考

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style>
.suckerdiv ul{
margin: 0;
padding: 0;
list-style-type: none;
width: 150px; /* Width of Menu Items */
border-bottom: 1px solid #ccc;
}

.suckerdiv ul li{
position: relative;
}

/*1st level sub menu style */
.suckerdiv ul li ul{
left: 149px; /* Parent menu width – 1*/
position: absolute;
width: 160px; /*sub menu width*/
top: 0;
display: none;
}

/*All subsequent sub menu levels offset */
.suckerdiv ul li ul li ul{
left: 159px; /* Parent menu width – 1*/
}

/* menu links style */
.suckerdiv ul li a{
display: block;
color: black;
text-decoration: none;
font:12px 宋体;
background: #fff;
padding: 5px 5px;
border: 1px solid #ccc;
border-bottom: 0;
}

.suckerdiv ul li a:visited{
color: black;
}

.suckerdiv ul li a:hover{
color: white;
background-color: gray;
}

.suckerdiv .subfolderstyle{
background: url(images/arrow-list.gif) no-repeat center right;
}

/* Holly Hack for IE /*/
* html .suckerdiv ul li { float: left; height: 1%; }
* html .suckerdiv ul li a { height: 1%; }
/* End */
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="" />
<meta name="description" content="SUNS" />
<title>suns</title>
<script type="text/javascript">
//SuckerTree Vertical Menu (Aug 4th, 06)
//By Dynamic Drive: http://www.dynamicdrive.com/style/

var menuids=["suckertree1"] //Enter id(s) of SuckerTree UL menus, separated by commas

function buildsubmenus(){
for (var i=0; i<menuids.length; i++){
var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
for (var t=0; t<ultags.length; t++){
ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle"
ultags[t].parentNode.onmouseover=function(){
this.getElementsByTagName("ul")[0].style.display="block"
}
ultags[t].parentNode.onmouseout=function(){
this.getElementsByTagName("ul")[0].style.display="none"
}
}
}
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus)
</script>
</head>
<body>

<div class="suckerdiv">
<ul id="suckertree1">
[myli]0,1[/myli]
</ul>
</div>

</body>
</html>

本文链接:https://www.dnwfb.com/756.html,转载请注明出处。
0

评论0

没有账号? 注册  忘记密码?