Edit: This is not working (tested). The problem is that you need to also send out headers and perhaps use another function aside from include. I thought that would be an easy way around it. Realistically the easiest way will just be to figure out how to insert php code into smarty.
There's another, easy way to do this, than having to use smarty.
Save the following code as image.php and embed it as html:
<img src="image.php".......>
PHP Code:
<?php
$time_hour = "15";
/* This sets the $time variable to the current hour in the 24 hour clock format */
$time = date("H");
if ($time < $time_hour) {
include('image1.jpg'); //the "before" image
} else {
/* the time is greater than or equal to 1500 hours, show imageB*/
include('image2.jpg'); //the "after" image
}
?>
Remember: all of these paths must be relative to the correct locations of the files.
Basically this will use a .php page to serve the correct image based on the time -- the php page itself will "be" the image.
RE: code above:
I removed the floating "else" at the end of the code. This might cause a parse error, or at least is not required.
I also removed the second if: it's the opposite of the first, so that just makes for longer code.
Bookmarks