$_server['script_name']

Reply

Join Date: Apr 2008
Posts: 9
Reputation: phploveisgood is an unknown quantity at this point 
Solved Threads: 0
phploveisgood phploveisgood is offline Offline
Newbie Poster

Re: $_server['script_name']

 
0
  #11
May 11th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: $_server['script_name']

 
0
  #12
May 15th, 2008
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/


  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?
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 31
Reputation: rgviza is an unknown quantity at this point 
Solved Threads: 5
rgviza rgviza is offline Offline
Light Poster

Re: $_server['script_name']

 
0
  #13
May 15th, 2008
I'm actually surprised this works at all anywhere because the result will look like:
  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:
  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:
  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
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 9
Reputation: phploveisgood is an unknown quantity at this point 
Solved Threads: 0
phploveisgood phploveisgood is offline Offline
Newbie Poster

Re: $_server['script_name']

 
0
  #14
May 15th, 2008
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:

  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
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 31
Reputation: rgviza is an unknown quantity at this point 
Solved Threads: 5
rgviza rgviza is offline Offline
Light Poster

Re: $_server['script_name']

 
0
  #15
May 15th, 2008
there's still no space between the attributes.
try
  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=
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 9
Reputation: phploveisgood is an unknown quantity at this point 
Solved Threads: 0
phploveisgood phploveisgood is offline Offline
Newbie Poster

Re: $_server['script_name']

 
0
  #16
May 15th, 2008
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.


  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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: $_server['script_name']

 
0
  #17
May 15th, 2008
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.
Last edited by amigura; May 15th, 2008 at 6:03 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 9
Reputation: phploveisgood is an unknown quantity at this point 
Solved Threads: 0
phploveisgood phploveisgood is offline Offline
Newbie Poster

Re: $_server['script_name']

 
0
  #18
May 16th, 2008
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.

  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
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 9
Reputation: phploveisgood is an unknown quantity at this point 
Solved Threads: 0
phploveisgood phploveisgood is offline Offline
Newbie Poster

Re: $_server['script_name']

 
0
  #19
May 16th, 2008
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.

  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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: $_server['script_name']

 
0
  #20
May 16th, 2008
the original code works ok apart from missing ;
u should use code tags [CODE ] code here [/CODE ]

  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>
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC