I use these files as base for my website:
The 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>
The default.php
:
<body>
<div id='navcontainer'>
<?php include ("menu.php"); ?>
</div>
<div id='content'>
<?php include ($p); ?>
</div>
The 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;}
The home.php
and all pages:
<p>Hello world!</p>
I wonder if it is possible to get my menu.php
to switch class to nav active
on the <li>
items based on what page is currently visited.
Any ideas?
Using just php, you can create an extra variable
I could not get
to work. What worked for me was
You can give some id in REQUEST and then add:
then