•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 374,011 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,768 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 793 | Replies: 19
![]() |
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/
i don't know how you got it setup but you could think about a include config style file
wat does $style_home do?
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?
•
•
Join Date: May 2008
Posts: 31
Reputation:
Rep Power: 1
Solved Threads: 5
I'm actually surprised this works at all anywhere because the result will look like:
when printed to the page. You need a space before style=
so you end up with:
If the browser parses attributes correctly it won't see the style at all as it is.
You can almost always sanity check whether it's a php problem or html by echoing "Made it to here" or something within the conditional logic:
if it prints the test and the script exits, php is fine.
-r
<li class="linkLevel01"><a href="index.php" class="homy"style="background-color: #6C674F">Home</a></li>
so you end up with:
<li class="linkLevel01"> -------------------------------| |----------- <a href="index.php" class="homy" style="background-color:#6C674F">Home</a> </li>
If the browser parses attributes correctly it won't see the style at all as it is.
You can almost always sanity check whether it's a php problem or html by echoing "Made it to here" or something within the conditional logic:
#
if($_SERVER['SCRIPT_NAME'] == 'index.php')
#
{
#
//sanity check
echo "Made it to here";exit;
$style_home = 'style="background-color: #6C674F"';
#
}-r
•
•
Join Date: Apr 2008
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
Hallo, thanks again. The $style_home gives the active link another color, to specify the user which page he is viewing. This is part of the code:
php Syntax (Toggle Plain Text)
<!-- Navigation item --> <?php $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php"); if ($bobo) { $style_home = 'style="background-color: #6C674F"'; } ?> <ul> <li class="linkLevel01"> <a href="index.php" class="homy"<?php echo $style_home ?>>Home</a> </li> </li> <li class="linkLevel01"> <a href="kamine.php?page=1" class="homy">Kamine</a> </li> <!-- Navigation item --> <li class="linkLevel01"> <a href="#" class="homy">Accessoires<!--[if IE 7]><!--></a> <!--<![endif]--> <!--[if lte IE 6]><table><tr><td><![endif]--> <ul class="dropdown"> <div class="dropdownMob"> <li><a href="kaminkoerbe.php"> <h6 class="ontok">Kaminkörbe</h6></a></li> <li><a href="kamineinsaetze.php"> <h6 class="ontok">Kamineinsätze</h6></a></li> <li><a href="kaminvorsaetze.php"> <h6 class="ontok">Kaminvorsätze</h6></a></li> </div> </ul><!--[if lte IE 6]></td></tr></table></a><![endif]--> </li>
Last edited by peter_budo : May 16th, 2008 at 5:58 pm. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: May 2008
Posts: 31
Reputation:
Rep Power: 1
Solved Threads: 5
there's still no space between the attributes.
try
you need a space in front of style=
try
$bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php");
if ($bobo)
{
$style_home = ' style="background-color: #6C674F"';
you need a space in front of style=
•
•
Join Date: Apr 2008
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
It works fine on index.php. But when trying it on kamin.php, the style will appear on both links. Bobo is the folder on the sever and in this folder is all my php files.
php Syntax (Toggle Plain Text)
<?php $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php"); if ($bobo) { $style_home = 'style= "background-color: #6C674F"'; } $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/kanim.php"); if ($bobo) { $style_home = 'style= "background-color: #6C674F"'; } ?> <ul> <li class="linkLevel01"><a href="index.php" class="homy"<?php echo $style_home ?>>Home</a></li> </li> <li class="linkLevel01"><a href="kamine.php?page=1" class="homy"<?php echo $style_home ?>>Kamine</a></li>
Last edited by peter_budo : May 16th, 2008 at 5:59 pm. Reason: Keep It Organized - please use [code] tags
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
i tried no space thing and it works. i'm guessing due to " " closing var before it.
•
•
•
•
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.
Last edited by amigura : May 15th, 2008 at 5:03 pm.
•
•
Join Date: Apr 2008
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
When I code it this way, the styling will display on both links at thesame time. And I want it one at a time. That is, when on index.php, show style and when kamin.php, show style.
php Syntax (Toggle Plain Text)
<!-- Navigation item --> <?php $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php"); if ($bobo) { $style_home = ' style="background-color: #6C674F"'; } ?> <?php $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/kamine.php?page=1"); if ($bobo) { $style_kamine = ' style="background-color: #6C674F"'; } ?> <ul> <li class="linkLevel01"> <a href="index.php" class="homy"<?php echo $style_home?> exit;>Home</a> </li> </li> <li class="linkLevel01"> <a href="kamine.php?page=1" class="homy"<?php echo $style_kamine?>>Kamine</a> </li>
Last edited by peter_budo : May 16th, 2008 at 6:01 pm. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Apr 2008
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
When I code it this way, the styling will display on both links at thesame time. And I want it one at a time. That is, when on index.php, show style and when kamin.php, show style.
php Syntax (Toggle Plain Text)
<!-- Navigation item --> <?php $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php"); if ($bobo) { $style_home = ' style="background-color: #6C674F"'; } ?> <?php $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/kamine.php?page=1"); if ($bobo) { $style_kamine = ' style="background-color: #6C674F"'; } ?> <ul> <li class="linkLevel01"><a href="index.php" class="homy"<?php echo $style_home?>>Home</a></li> </li> <li class="linkLevel01"><a href="kamine.php?page=1" class="homy"<?php echo $style_kamine?>>Kamine</a></li>
Last edited by peter_budo : May 16th, 2008 at 6:01 pm. Reason: Keep It Organized - please use [code] tags
the original code works ok apart from missing ;
u should use code tags [CODE ] code here [/CODE ]
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>![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- Help beta testing new CMS (PHP)
- url splitting (PHP)
- code output not correct (PHP)
- Making a static but yet a dynamic navigation (PHP)
- Need HELP in pagination (PHP) (PHP)
- pagination of mysql query results (PHP)
- Font Size Problem (PHP)
- Display URL (PHP)
- Error getting forms to send information (PHP)
Other Threads in the PHP Forum
- Previous Thread: Remove Non Printing Characters From Text
- Next Thread: help with code


Linear Mode