Forum Moderators: coopster

Message Too Old, No Replies

PHP Condition help

         

pmgreen

1:22 pm on Jun 2, 2010 (gmt 0)

10+ Year Member



I'm new to PHP so not sure this is possible but hope the gurus here can help me. I want to display one image on the homepage and another on any page not the homepage.

Something like if the URL equal index, display image someimage.png else display anotherimage.png

Can someone please help.

Readie

1:53 pm on Jun 2, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have the following code on all your pages where you want the image to appear:

echo (isset($image_pages_display))? '/images/image_on_home.jpg' : '/images/image_not_on_home.jpg';

And only on your homepage, anywhere above that line:
$image_pages_display = 1;

pmgreen

6:53 pm on Jun 2, 2010 (gmt 0)

10+ Year Member



Thanks Readie. I'm using Joomla so don't think this will work as there are no real pages. Any other ideas?

jason_m

8:23 pm on Jun 2, 2010 (gmt 0)

10+ Year Member



not sure what you're going for pmgreen, but if you do not have any real pages, then how do you have a homepage?

edit:

maybe this will help you in your direction.

1-detect the current URL
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}

2-use this to create some conditional on your page
<?
if($pageURL==...){
echo 'yourImage1.png';
}else{

echo 'yourImage2.png';
}
?>


haven't used joomla, but to be honest, you might have better luck learning languages outside of some development environment and just going for it on your own.