April 20th, 2007

How to detect the home page on a Joomla site

Create beautiful Joomla websites with a flexible layout from iJoomla.com

Recently I had to add some PHP code to the template of a Joomla site I run, but I wanted that code to run on the homepage only. Considering the fact that I'm using an SEF component on the site, it was tricky, but here's the line of PHP code I was able to do it with:

$pge = $_SERVER['QUERY_STRING']; if ($pge == "/index.php"||$pge == "") {
     //do stuff
}

Create beautiful Joomla websites with a flexible layout from iJoomla.com

6 Responses to ' How to detect the home page on a Joomla site '

Subscribe to comments with RSS or TrackBack to ' How to detect the home page on a Joomla site '.

  1. Lever said,

    on April 26th, 2007 at 5:41 am

    Top man, that's a simple enough line… all I gotta do now is think of stuff to do now that I know it's do-able.

  2. Joomla Developer said,

    on May 21st, 2007 at 7:04 am

    Had to Modify your code to work for me as below

    Your Page Title ";
    }
    ?>

  3. Joomla Developer said,

    on May 21st, 2007 at 7:06 am

    Your Page Title ";
    } ?>

  4. Joomla Developer said,

    on May 21st, 2007 at 7:07 am

    Your Page Title ";
    }
    ?>
  5. Joomla Developer said,

    on May 21st, 2007 at 7:25 am

    $pge = $_SERVER['QUERY_STRING']; if ($pge == "/index.php"||$pge == ""||$pge == "option=com_frontpage&Itemid=1") {
    //do stuff
    echo " Your Page Title ";
    }

  6. herc said,

    on May 29th, 2007 at 4:25 am

    thank you very very much! that literally solved my provlem with adding a special flash script just to the startpage.

    you are genius! thanks again!

Leave a reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word