qinsilandiao

本章我们开始进行后台管理界面的设计,本节课设计一下导航栏设计。
一. 退出登录
//logout.php
<?php
session_start();
session_destroy();
header(\'location:login.php\');
?>

二. 导航栏设计
根据生成的 JSON 方案,表如下:

//nav.php
<?php
require \'config.php\';
$id = isset($_POST[\'id\']) ? $_POST[\'id\'] : 0;
$query = mysql_query("SELECT id,text,state,iconCls,url FROM
easyui_nav WHERE nid=\'$id\'") or die(\'SQL 错误!\');
$json = \'\';
while (!!$row = mysql_fetch_array($query, MYSQL_ASSOC)) {
$json .= json_encode($row).\',\';
}

$json = substr($json, 0, -1);
echo \'[\'.$json.\']\';
mysql_close();
?>
//tree 结构
$(\'#nav\').tree({
url : \'nav.php\',
lines : true,
onLoadSuccess : function (node, data) {
var _this = this;
if (data) {
$(data).each(function (index, value) {
if (this.state == \'closed\') {
$(_this).tree(\'expandAll\');
}
});
}
},
onClick : function (node) {
if (node.url) {
if ($(\'#tabs\').tabs(\'exists\', node.text)) {
$(\'#tabs\').tabs(\'select\', node.text)
} else {
$(\'#tabs\').tabs(\'add\', {
title: node.text,
closable: true,
iconCls : node.iconCls,
href : node.url + \'.php\',
});
}
}
}
});

分类:

技术点:

相关文章: