if "URL" then...

Discussion in 'PHP' started by david01130, Oct 4, 2010.

  1. #1
    I have a top navbar on my site that is screwing up my feed. Is there a way to create an "if" statement thats asks: if it is this url, then follow this code, else.....
     
    david01130, Oct 4, 2010 IP
  2. david01130

    david01130 Member

    Messages:
    106
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #2
    I found this code:

    <?php
    $homepage = "/";
    $currentpage = $_SERVER['REQUEST_URI'];
    if($homepage==$currentpage) {
    include('homepage-ads.php');
    }
    ?>

    Is there a way to change the include('homepage-ads.php'); to just a long string of code?
     
    david01130, Oct 4, 2010 IP
  3. lowridertj

    lowridertj Well-Known Member

    Messages:
    2,882
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    195
    #3
    <?php
    $homepage = "/"; //page that you want to show your feed on
    $currentpage = $_SERVER['REQUEST_URI']; // page you are on
    if($homepage==$currentpage) { //verifies if same then show feed
    // Remove include('homepage-ads.php');
    ?>
    start feed here
    <?php
    }
    ?>
    PHP:
     
    lowridertj, Oct 4, 2010 IP
  4. david01130

    david01130 Member

    Messages:
    106
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #4
    thanks!! that worked! reps!!
     
    david01130, Oct 4, 2010 IP
  5. sinha.sidhi

    sinha.sidhi Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i think it not take url condition....
     
    sinha.sidhi, Aug 29, 2011 IP
  6. HalvinCarris

    HalvinCarris Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    But it works
     
    HalvinCarris, Sep 3, 2011 IP