echo or print the variable to see what it actually is.
<?php
if($_SERVER['SCRIPT_NAME'] == '/bobo/index.php') {
$style_home = 'style="background-color: #6C674F"';
}
echo $_SERVER['SCRIPT_NAME'];
?>
buddylee17
Practically a Master Poster
697 posts since Nov 2007
Reputation Points: 232
Solved Threads: 137
Okay, that means that $_SERVER['SCRIPT_NAME'] equals index.php. Therefore, compare the current page($_SERVER['SCRIPT_NAME']) to index.php:
<?php
if($_SERVER['SCRIPT_NAME'] == 'index.php')
{
$style_home = 'style="background-color: #6C674F"';
}
?>
buddylee17
Practically a Master Poster
697 posts since Nov 2007
Reputation Points: 232
Solved Threads: 137
comparing $_SERVER['SCRIPT_NAME'] == 'index.php' will not work for you as /bobo/index.php' and '/aktuelle seite/index.php' will give same style.
try below to see wat you get
echo $_SERVER['PHP_SELF'];
amigura
Junior Poster in Training
72 posts since Jan 2008
Reputation Points: 11
Solved Threads: 7
hmm for both $_SERVER['SCRIPT_NAME'] and $_SERVER['PHP_SELF'] not to work you might have a problem with your php.
$bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php");
if ($bobo)
{
$style_home = 'style="background-color: #6C674F"';
}
or
if ($_SERVER['REQUEST_URI']=="/bobo/index.php")
{
$style_home = 'style="background-color: #6C674F"';
}
amigura
Junior Poster in Training
72 posts since Jan 2008
Reputation Points: 11
Solved Threads: 7
ok did u change index.php to other file names. u didn't say which one was working so i choose this. it will work on all files in bobo folder.
but i will also say that any folder combination will set it off also e.g.
folder/bobo/newfolder/
bobo/folder/newfolder/
folder/bobo/bobo/
$bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/");
if ($bobo)
{
$style_home = 'style="background-color: #6C674F"';
}
i don't know how you got it setup but you could think about a include config style file
wat does $style_home do?
amigura
Junior Poster in Training
72 posts since Jan 2008
Reputation Points: 11
Solved Threads: 7
it is because u have $style_home on all links therefore when $style_home is active for one link it will do it for all links. do $style_home1 $style_home2 or something
there's still no space between the attributes.
i tried no space thing and it works. i'm guessing due to " " closing var before it.
amigura
Junior Poster in Training
72 posts since Jan 2008
Reputation Points: 11
Solved Threads: 7
the original code works ok apart from missing ;
u should use code tags [CODE ] code here [/CODE ]
<!-- Navigation item -->
<?php
if (strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php"))
{
$style_home = 'style="background-color: #6C674F"';
}
elseif (strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/kamine.php"))
{
$style_kamine = 'style="background-color: #6C674F"';
}
?>
<ul>
<li class="linkLevel01"><a href="index.php" class="homy" <?php echo $style_home; ?>>Home</a></li>
<li class="linkLevel01"><a href="kamine.php?page=1" class="homy" <?php echo $style_kamine; ?>>Kamine</a></li>
</ul>
amigura
Junior Poster in Training
72 posts since Jan 2008
Reputation Points: 11
Solved Threads: 7