WordPress.org

Support

Support » WP-Advanced » [Resolved] $_SERVER[’SCRIPT_NAME’ issues

[Resolved] $_SERVER[’SCRIPT_NAME’ issues

  • Hello,

    I am trying to combine dynamic menus (described so well in the codex) with another level of functionality that involves specifying a different php file for each top level page (which contain the subpages). Sounds complicated, well here’s an example of how it should look: http://www.bipcorporate.com

    What I don’t seem to be able to work out is how to specify a specific php rule. This is what I’ve worked out so far:

    <?php
    if ($_SERVER[’SCRIPT_NAME’]='/about') {
    include( TEMPLATEPATH . '/nav/about.php');
    }
    elseif ($_SERVER[’SCRIPT_NAME’]='/contact') {
    include( TEMPLATEPATH . '/nav/contact.php');
    }
    else {
    include( TEMPLATEPATH . '/nav/home.php');
    }
    ?>

    But it doesn’t work.

    Any ideas?

    Thanks,

    Neil

Viewing 2 replies - 1 through 2 (of 2 total)
  • i’d try using $_SERVER[“REQUEST_URI”] instead of $_SERVER[‘SCRIPT_NAME’].

    But how does it not work exactly? Does it allways show home.php?

    D

    Okay, I managed to sort it out, here is the solution:

    
    <?php
    
      if(stristr($_SERVER['REQUEST_URI'], '/about')){
             include( TEMPLATEPATH . '/nav/about.php');
      }elseif(stristr($_SERVER['REQUEST_URI'], '/brands')){
             include( TEMPLATEPATH . '/nav/contact.php');
      }elseif(stristr($_SERVER['REQUEST_URI'], '/investor')){
             include( TEMPLATEPATH . '/nav/contact.php');
      }elseif(stristr($_SERVER['REQUEST_URI'], '/careers')){
             include( TEMPLATEPATH . '/nav/contact.php');
      }elseif(stristr($_SERVER['REQUEST_URI'], '/media')){
             include( TEMPLATEPATH . '/nav/contact.php');
      }elseif(stristr($_SERVER['REQUEST_URI'], '/contact')){
             include( TEMPLATEPATH . '/nav/contact.php');
      }else{
             include( TEMPLATEPATH . '/nav/home.php');
      } 
    
    ?>
    

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] $_SERVER[’SCRIPT_NAME’ issues’ is closed to new replies.