Home » Code

PHP: Determine if on Joomla Main page

21 November 2007 No Comment

<?php //DE script to determine the page URL to $pageURL

function curPageURL() {

$pageURL = ”;

if ($_SERVER["HTTPS"] == “on”) {$pageURL .= “s”;}

//$pageURL .= “://”;

if ($_SERVER["SERVER_PORT"] != “80″) {

 $pageURL .= ‘DE’.$_SERVER["SERVER_NAME"].”:”.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];

} else {

// $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];

 $pageURL .=$_SERVER["REQUEST_URI"];

}

return $pageURL;

}

?>

<?php

$de_URL =curPageURL();

//Test Search string code

$string = “com_frontpage”;

$container = $de_URL;

if(strstr($container,$string)) {

echo “This is the front page”;

} else {

echo “This is NOT the front page”;

}

?>

Leave your response!

You must be logged in to post a comment.