View Single Post
Old 08-25-2011, 11:56 AM  
robber
Web Developer
 
Industry Role:
Join Date: Jan 2011
Location: UK
Posts: 264
Hi Morten,

If I'm understanding your original post correctly, you have pictures sorted into files and you want to show specific pictures on specific days, is this going to be a whole site theme or only specific pictures which will change as you could almost set it up so each picture you want to include is checked otherwise you include a default image in its place (so you don't get broken images showing)

The top of you file would include some code like:
Code:
<?php
$date = date('Y-m-d');
if(!is_dir($date)){$date="default";}
?>
This would do a simple check to make sure the folder is there, this would be simple as long as you have a picture available for each one on the page which is linking so your picture tags on the page would be some thing like:

Code:
<img src="<?php echo $date; ?>/img1.png">
<img src="<?php echo $date; ?>/img2.png">
<img src="<?php echo $date; ?>/img3.png">
This would do the basics of what you need, but if you were wanting to be a bit more technical, you could add a second check to make sure the file exists, to make this simple it might be easier to write a little function, so under the header section add: (Make sure it is after the date check)
Code:
function fcheck($name){
if(file_exists($date."/".$name)){
return $date."/".$name;
}else{
return "default/".$name;
}}
Then all you would need to do to include the file is:

Code:
<img src="<?php echo fcheck("img1.png"); ?>">
<img src="<?php echo fcheck("img2.png"); ?>">
<img src="<?php echo fcheck("img3.png"); ?>">
Hope this helps, if you are unsure please ask

Kind Regards

Rob
robber is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook