我使用这些文件作为我网站的基础:
menu.php
: _
$p = $_GET['p'];
switch($p)
{
case "home":
$p = "page/home.php";
break;
case "customers":
$p = "page/customers.php";
break;
default:
$p = "page/home.php";
break;
}
<ul id='nav'>
<li>Title</li>
<ul>
<li class="nav active"><a href="?p=home">Home</a></li>
<li><a href="?p=customers">Customers</a></li>
</ul>
</ul>
default.php
: _
<body>
<div id='navcontainer'>
<?php include ("menu.php"); ?>
</div>
<div id='content'>
<?php include ($p); ?>
</div>
style.css
: _
#navcontainer {margin:0; padding:0; width:220px;float:left;}
#nav li {background:#36393D; color:#fff; padding:5px 3px 5px 20px; margin:4px;border-left:5px solid #3F4C6B;}
#nav ul li{display:block; padding:3px; background:#fff; color:#000;border:none; padding:3px 0 3px 30px;}
#nav ul li:hover, #nav ul li.active {background:#eee; cursor:pointer; border-left:5px solid #4096EE;padding:3px 0 3px 25px;}
#nav ul li a {text-decoration:none; color:#000;}
和home.php
所有页面:
<p>Hello world!</p>
我想知道是否有可能让我根据当前访问的页面menu.php
切换到nav active
项目。<li>
有任何想法吗?