Different content from same page

Discussion in 'PHP' started by mgrohan, Nov 1, 2006.

  1. #1
    Hi,
    I'm using a script that is based on a single paged template file.

    I am trying to get different content to be displayed on the index page, currently putting it into the template currently is making it display on everypage instead of just the index page.

    Was wondering in php if it was possible to make a condition based on the url (and then i could use a SSI), such as:

    if url = mysite.com/index.php
    then inlcude-onlydisplayonindex.php
    else
    ..
    ..

    Could anyone help out or point me in the right direction. Cheers.
     
    mgrohan, Nov 1, 2006 IP
  2. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    yes you can :
    
    <?
    $currentFile = $_SERVER["PHP_SELF"];
    echo $currentFile; //testing purposes you can remove that later
    if ($currentFile == 'your target url')
    { include 'somefile.php'; }
    ?>
    
    Code (markup):
     
    maiahost, Nov 1, 2006 IP
  3. mgrohan

    mgrohan Active Member

    Messages:
    671
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Thanks, tried it but it didn't work
     
    mgrohan, Nov 2, 2006 IP
  4. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #4
    OK what did the echo return ? and what page do you compare it to ?
     
    maiahost, Nov 2, 2006 IP