genkidave Posted November 5, 2003 Posted November 5, 2003 Is there a way to have a script that rotates automatically starting on the first of the month? E.g: There are 4 seasons in the year, and you have created 4 CSS templates for those seasons, then on the day that the season begins (Dec 21 is Winter) then the winter.css file would be activated and display that particualr theme... Am I making any sense here? Anyway, if you don't have a short circuit while trying to figure out what I'm asking, and know the answer to the question, PLUS have a script or know where I can find one, please let me know. Thanks Genki Dave Quote
TCH-JimE Posted November 5, 2003 Posted November 5, 2003 Hi, yes that should be easy to do in javascript. Get it to check the date, then depending on the date, just make it write in the line to the linked CSS. I don't know of a script, but you could hunt for one that say writes something dependant on date. then just modify that Jim Quote
borfast Posted November 5, 2003 Posted November 5, 2003 (edited) Hi Dave! JavaScript would work, just as Jim suggested. Still, I'd go for PHP, because not everyone has JavaScript enabled on their browsers, so with PHP you have the guarantee that the random stylesheet is selected, because PHP runs on the server and is not dependant on any user preferences. Here's a little example (not valid HTML code and I didn't test it, it's just for you to get the picture): ><html> <head> <title>Your page title</title> <?php $date = getdate(); // this mktime will return a UNIX timestamp for December 21 of the current year if ($date >= mktime(0, 0, 0, 12, 21)) $css = 'winter.css'; // this mktime will return a UNIX timestamp for September 21 of the current year else if ($date >= mktime(0, 0, 0, 9, 21)) $css = 'autumn.css'; // this mktime will return a UNIX timestamp for June 21 of the current year else if ($date >= mktime(0, 0, 0, 6, 21)) $css = 'summer.css'; // this mktime will return a UNIX timestamp for March 21 of the current year else if ($date >= mktime(0, 0, 0, 3, 21)) $css = 'spring.css'; ?> <link rel="stylesheet" type="text/css" href="<?php echo $css; ?>" /> </head> <body> blablablabla blablablabla </body> </html> Adjust the mktime() dates to the correct ones. I never know when seasons begin Edited November 5, 2003 by borfast Quote
genkidave Posted November 7, 2003 Author Posted November 7, 2003 Hey thanks! I don't know anything at all about PHP (not yet anyway), but I'll try it out on a couple of dates and see if the switch works. You da man! thanks for giving me a path to follow dude! Genki Dave Quote
genkidave Posted November 9, 2003 Author Posted November 9, 2003 Now I just have to find a FREE PHP host. Quote
borfast Posted November 9, 2003 Posted November 9, 2003 Well, I thought you had your site hosted here at TCH - every server has PHP installed and a lot of other goodies It's not free but $44 for a year of hosting, with the support quality and the amount of stuff you get, it's practically the same as free Quote
genkidave Posted November 9, 2003 Author Posted November 9, 2003 Alas, I am a man with a tither, which is about to whither. I can't afford to pay for a web site for 2 reasons. I have no credit card, and my buget is tighter than a bow's string. Thanks for the help though. I'll find one. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.