Home >Backend Development >PHP Tutorial >闲来无事,持续更新~要做一个有追求的版本,列表页增加树形菜单

闲来无事,持续更新~要做一个有追求的版本,列表页增加树形菜单

WBOY
WBOYOriginal
2016-06-13 11:26:19857browse

闲来无事,继续更新~要做一个有追求的版本,列表页增加树形菜单

本帖最后由 xjl756425616 于 2013-06-04 20:00:30 编辑 版本再次更新,取了一个英文名 "Pursue",

地址:http://www.youyax.com/forum/
PHP开源论坛系统--YouYaX Pursue版本更新

本次更新在列表页面加入了树形菜单功能。
直接写在列表页里了

树形js代码是抄袭的,自己主要是实现了和数据库连接。
之前在官网列表页用了效果更好的ztree插件,不过它是基于jquery实现的,
还是不喜欢用jquery


更新代码部分
<div   style="max-width:90%" id="treediv" class="tree"></div><br /><script type="text/javascript"><br />var data=[<br /><?php<br />	$sql="select bid,count(distinct bid),max(ssort) as st from " .C('db_prefix'). "small_block group by bid order by st desc";<br />	$query=mysql_query($sql);<br />	$num=mysql_num_rows($query);<br />	if($num>0){<br />		while($arr=mysql_fetch_array($query)){<br />			$ssql="select * from " .C('db_prefix'). "big_block where id=".$arr['bid'];<br />			$squery=mysql_query($ssql);<br />			$snum=mysql_num_rows($squery);<br />			if($snum>0){<br />				while($sarr=mysql_fetch_array($squery)){<br />?><br />{t:'<?php echo $sarr['bzone']; ?>',s:[<?php		<br />					$ssql2="select * from " .C('db_prefix'). "small_block where bid=".$sarr['id'];<br />					$squery2=mysql_query($ssql2);<br />					$snum2=mysql_num_rows($squery2);<br />					if($snum2>0){<br />					while($sarr2=mysql_fetch_array($squery2)){<br />						?>{t:'<?php echo $sarr2['szone'];?>',url:'{site}/index.php/List{url}index{url}f{url}<?php echo $sarr2['id']; ?>{shtml}'},<?php<br />					 }<br />				 }<br />			?><br />		]},<?php<br />				}<br />			}<br />		}<br />	}<br />	?><br />];<br />var et=new Tree(data,'treediv');<br />var dts=document.getElementById("treediv").getElementsByTagName("dt");<br />for(var i=0;i<dts.length;i++){<br />if(document.all) {dts[i].click();}<br />else {<br />  	var e = document.createEvent("MouseEvents");<br />  	e.initEvent("click", false, false);<br />  	dts[i].dispatchEvent(e);<br />  }<br />}<br />var navH = document.getElementById("treediv").offsetTop;<br />window.onscroll=function(){<br />    var scroH = window.pageYOffset|| document.documentElement.scrollTop || document.body.scrollTop;<br />    if (scroH >= navH) {<br />       document.getElementById("treediv").style.position="fixed";<br />       document.getElementById("treediv").style.top=0;<br />    } else if (scroH < navH) {<br />       document.getElementById("treediv").style.position="absolute";<br />       document.getElementById("treediv").style.top="30px";<br />    }<br />}<br /></script>
YouYaX
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn