Thursday, December 17, 2009

Joomla 1.5 & 1.0 - Specific modules/script based on URL (PHP Hack)

The "%" in <%script src='XXXXX' type='text/javascript'><%/script> is simply there to show this code but would be removed

< ?php
$currentpage = $_SERVER['REQUEST_URI'];
if($currentpage=="/" || $currentpage=="/index.php" || $currentpage=="" ) {
echo "<%script src='XXXXX' type='text/javascript'><%/script>";
} else {
echo "";
};
?>


This will show your script on http://yourdomain.com/ , http://yourdomain.com/index.php and http://yourdomain.com . And will not show this on any other page.

The first echo ""; will be what is shown on these pages (Your script/module) and the second echo ""; will be what is shown on all the other pages (In this case nothing)

You can change ($currentpage=="/" || $currentpage=="/index.php" || $currentpage=="" ) to represent your pages.

You can change <%script src='XXXXX' type='text/javascript'><%/script> to to load module position special (Joomla 1.5)

No comments:

Post a Comment