1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

detect home page in Joomla

Discussion in 'PHP' started by frankcow, Apr 13, 2007.

  1. #1
    does anyone have a quick snippet of code to place in a template, that would enable me to detect if current item or URL is the homepage?

    Basically, I'm trying to load something on the homepage only, like in WordPress how you'd use if(is_home())

    thanks
     
    frankcow, Apr 13, 2007 IP
  2. minute

    minute Peon

    Messages:
    443
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <? $string = $PHP_SELF; if ($string == "/index.php") {include('whatever.inc');}?>
    Code (markup):
    Anyway, there's probably a better way. I don't know if joomla has it's own functions for the home page like wordpress.
     
    minute, Apr 13, 2007 IP
  3. frankcow

    frankcow Well-Known Member

    Messages:
    4,859
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    180
    #3
    that didn't work
    isn't $PHP_SELF deprecated?
     
    frankcow, Apr 13, 2007 IP
  4. frankcow

    frankcow Well-Known Member

    Messages:
    4,859
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    180
    #4
    Here, I figured out the code to do it:
    $pge = $_SERVER['QUERY_STRING']; if ($pge == "/index.php"||$pge == "") {//do stuff}
    PHP:
     
    frankcow, Apr 13, 2007 IP
    commandos likes this.
  5. minute

    minute Peon

    Messages:
    443
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yep that looks good
     
    minute, Apr 13, 2007 IP