I own a VBulletin Forums in which I'd like the header image to change based on certain dates. (So my christmas logo will come up on the 16th, etc). I would like this to happen without having to go in and edit code every time. Anyone know how to pull this off?
you could just need to use some php and the date() function to determine the current date and then use an if else statement so if ( Date = this time - that time ) { display this image } else { display the original image } Someone else should be able to create the exact PHP for it, but that's the idea...
Try this code: (Assuming your images are stored in a folder called "images", 1 directory below where the code is executed.) <?php $mdarr= "18-25/12,13-20/05"; $miarr= "christmas.jpg,happy_birthday_jeet.jpg"; // Format explained below and why use this. $jtd= date("d"); $jtd= $jtd-7;// Minus 7 days to match above format. $jtd= $jtd . '-'. date("d"). '/' . date("m"); $jc=0; $r= explode(",",$mdarr); foreach($r as $v) { if($jtd==$v) { ++$jc; } } if($jc>0) { --$jc; $img= explode(",", $miarr); $img= $img[$jc]; print ' <img src="images/'. $img. '" alt="'. $img. '" /> '; } else { print ' <img src="images/default_logo.jpg" alt="default logo" /> '; } ?> About the date format. $mdarr= "18-25/12,13-20/05"; Here you can fit an array for all the dates you wish to change your image on. For example 25/12 (25 December.) Minus 7 days makes it: 18-25/12, so your image starts appearing 7 days before the actual festival. Add a "," sign and enter another date in same format. (Minus 7 days)-(Actual date)/(month) Add as many as you like. Which Image to use: $miarr= "christmas.jpg,happy_birthday_jeet.jpg"; Just enter the full image file name for each date at the same "number" position as it appears in date array. Seperated by "," sign. 18-25/12 was first item, so "christmas.jpg" is first in this array. and so on. Then replace the <img tag for your logo with this code above. Fill the array once, and probably will never have to touch it again... Bye
Hi, Thanks for the link and rep. Take a look at your blog. Towards the end of the post. The line where I said: "Then replace the <img tag..." The <img tag is getting displayed as html... Might wanna fix it. Bye