943,793 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 6164
  • PHP RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
May 11th, 2008
0

Re: $_server['script_name']

Thanks alot! It works! But only on the "Home link". I tried to put t on "About us, News etc. links" by using ELSEIF, it did not work. Regards
Reputation Points: 10
Solved Threads: 1
Newbie Poster
phploveisgood is offline Offline
14 posts
since Apr 2008
May 15th, 2008
0

Re: $_server['script_name']

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/


PHP Syntax (Toggle Plain Text)
  1. $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/");
  2. if ($bobo)
  3. {
  4. $style_home = 'style="background-color: #6C674F"';
  5. }

i don't know how you got it setup but you could think about a include config style file
wat does $style_home do?
Reputation Points: 11
Solved Threads: 7
Junior Poster in Training
amigura is offline Offline
71 posts
since Jan 2008
May 15th, 2008
0

Re: $_server['script_name']

I'm actually surprised this works at all anywhere because the result will look like:
PHP Syntax (Toggle Plain Text)
  1. <li class="linkLevel01"><a href="index.php" class="homy"style="background-color: #6C674F">Home</a></li>
when printed to the page. You need a space before style=

so you end up with:
PHP Syntax (Toggle Plain Text)
  1. <li class="linkLevel01">
  2. -------------------------------| |-----------
  3. <a href="index.php" class="homy" style="background-color:#6C674F">Home</a>
  4. </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:
PHP Syntax (Toggle Plain Text)
  1. #
  2. if($_SERVER['SCRIPT_NAME'] == 'index.php')
  3. #
  4. {
  5. #
  6. //sanity check
  7. echo "Made it to here";exit;
  8. $style_home = 'style="background-color: #6C674F"';
  9. #
  10. }
if it prints the test and the script exits, php is fine.

-r
Reputation Points: 18
Solved Threads: 5
Light Poster
rgviza is offline Offline
31 posts
since May 2008
May 15th, 2008
0

Re: $_server['script_name']

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)
  1. <!-- Navigation item -->
  2. <?php
  3.  
  4. $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php");
  5. if ($bobo)
  6. {
  7. $style_home = 'style="background-color: #6C674F"';
  8. }
  9.  
  10. ?>
  11. <ul>
  12.  
  13. <li class="linkLevel01">
  14. <a href="index.php" class="homy"<?php echo $style_home ?>>Home</a>
  15. </li>
  16. </li>
  17.  
  18. <li class="linkLevel01">
  19. <a href="kamine.php?page=1" class="homy">Kamine</a>
  20. </li>
  21.  
  22. <!-- Navigation item -->
  23.  
  24. <li class="linkLevel01">
  25. <a href="#" class="homy">Accessoires<!--[if IE 7]><!--></a>
  26. <!--<![endif]-->
  27. <!--[if lte IE 6]><table><tr><td><![endif]-->
  28. <ul class="dropdown">
  29. <div class="dropdownMob">
  30. <li><a href="kaminkoerbe.php">
  31. <h6 class="ontok">Kamink&ouml;rbe</h6></a></li>
  32. <li><a href="kamineinsaetze.php">
  33. <h6 class="ontok">Kamineins&auml;tze</h6></a></li>
  34. <li><a href="kaminvorsaetze.php">
  35. <h6 class="ontok">Kaminvors&auml;tze</h6></a></li>
  36. </div>
  37. </ul><!--[if lte IE 6]></td></tr></table></a><![endif]-->
  38. </li>
Last edited by peter_budo; May 16th, 2008 at 6:58 pm. Reason: Keep It Organized - please use [code] tags
Reputation Points: 10
Solved Threads: 1
Newbie Poster
phploveisgood is offline Offline
14 posts
since Apr 2008
May 15th, 2008
0

Re: $_server['script_name']

there's still no space between the attributes.
try
PHP Syntax (Toggle Plain Text)
  1. $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php");
  2. if ($bobo)
  3. {
  4. $style_home = ' style="background-color: #6C674F"';

you need a space in front of style=
Reputation Points: 18
Solved Threads: 5
Light Poster
rgviza is offline Offline
31 posts
since May 2008
May 15th, 2008
0

Re: $_server['script_name']

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)
  1. <?php
  2.  
  3. $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php");
  4. if ($bobo)
  5. {
  6. $style_home = 'style= "background-color: #6C674F"';
  7. }
  8.  
  9.  
  10. $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/kanim.php");
  11. if ($bobo)
  12. {
  13. $style_home = 'style= "background-color: #6C674F"';
  14. }
  15.  
  16. ?>
  17. <ul>
  18.  
  19. <li class="linkLevel01"><a href="index.php" class="homy"<?php echo $style_home ?>>Home</a></li>
  20. </li>
  21.  
  22. <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 6:59 pm. Reason: Keep It Organized - please use [code] tags
Reputation Points: 10
Solved Threads: 1
Newbie Poster
phploveisgood is offline Offline
14 posts
since Apr 2008
May 15th, 2008
0

Re: $_server['script_name']

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


Quote ...
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 6:03 pm.
Reputation Points: 11
Solved Threads: 7
Junior Poster in Training
amigura is offline Offline
71 posts
since Jan 2008
May 16th, 2008
0

Re: $_server['script_name']

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)
  1. <!-- Navigation item -->
  2. <?php
  3.  
  4. $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php");
  5. if ($bobo)
  6. {
  7. $style_home = ' style="background-color: #6C674F"';
  8. }
  9. ?>
  10.  
  11. <?php
  12. $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/kamine.php?page=1");
  13. if ($bobo)
  14. {
  15. $style_kamine = ' style="background-color: #6C674F"';
  16. }
  17.  
  18. ?>
  19. <ul>
  20.  
  21. <li class="linkLevel01">
  22. <a href="index.php" class="homy"<?php echo $style_home?> exit;>Home</a>
  23. </li>
  24. </li>
  25.  
  26. <li class="linkLevel01">
  27. <a href="kamine.php?page=1" class="homy"<?php echo $style_kamine?>>Kamine</a>
  28. </li>
Last edited by peter_budo; May 16th, 2008 at 7:01 pm. Reason: Keep It Organized - please use [code] tags
Reputation Points: 10
Solved Threads: 1
Newbie Poster
phploveisgood is offline Offline
14 posts
since Apr 2008
May 16th, 2008
0

Re: $_server['script_name']

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)
  1. <!-- Navigation item -->
  2. <?php
  3.  
  4. $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php");
  5. if ($bobo)
  6. {
  7. $style_home = ' style="background-color: #6C674F"';
  8. }
  9. ?>
  10.  
  11.  
  12. <?php
  13. $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/kamine.php?page=1");
  14. if ($bobo)
  15. {
  16. $style_kamine = ' style="background-color: #6C674F"';
  17. }
  18.  
  19. ?>
  20. <ul>
  21.  
  22.  
  23. <li class="linkLevel01"><a href="index.php" class="homy"<?php echo $style_home?>>Home</a></li>
  24. </li>
  25.  
  26.  
  27.  
  28. <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 7:01 pm. Reason: Keep It Organized - please use [code] tags
Reputation Points: 10
Solved Threads: 1
Newbie Poster
phploveisgood is offline Offline
14 posts
since Apr 2008
May 16th, 2008
0

Re: $_server['script_name']

the original code works ok apart from missing ;
u should use code tags [CODE ] code here [/CODE ]

PHP Syntax (Toggle Plain Text)
  1. <!-- Navigation item -->
  2. <?php
  3.  
  4. if (strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php"))
  5. {
  6. $style_home = 'style="background-color: #6C674F"';
  7. }
  8. elseif (strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/kamine.php"))
  9. {
  10. $style_kamine = 'style="background-color: #6C674F"';
  11. }
  12.  
  13. ?>
  14. <ul>
  15.  
  16. <li class="linkLevel01"><a href="index.php" class="homy" <?php echo $style_home; ?>>Home</a></li>
  17.  
  18. <li class="linkLevel01"><a href="kamine.php?page=1" class="homy" <?php echo $style_kamine; ?>>Kamine</a></li>
  19.  
  20. </ul>
Reputation Points: 11
Solved Threads: 7
Junior Poster in Training
amigura is offline Offline
71 posts
since Jan 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Remove Non Printing Characters From Text
Next Thread in PHP Forum Timeline: help with code





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC