I am trying to setup my site so that when I edit one file it edi开发者_StackOverflow中文版ts all the header or footer. but with the header I there is a current, can someone give me a script so that it will add:<li id="current" class="grey active item1">
infront of the "<a href
" and if it isnt currently "active" it will add: <li class="grey item26">
infront of the "<a href
", would prefer this in PHP but javascript would be fine aswell.
Sources for you to look at if you need any more info:
www.isgclan.com
www.isgclan.com/test.php
www.isgclan.com/template/main/header.php
The file that starts all this is just:
<?php
session_start();
require('template/main/header.php');
require("template/partnerscontent.php");
require("template/main/footer.php");
?>
This sounds like it is a active menu item related question...
When you include/require files they inherit the scope of where they were called from. See Variable scope.
So from test.php you could set a variable
$active = 'test';
And then in the header.php file you can check that variable
<li <?php
if ($active == 'test')
echo 'id = "current" class="grey active item1"';
else
echo 'class=""grey item26"'
?>>
Then in other files you can set $active to something else and have that handle this.
精彩评论