Jump to content

Recommended Posts

Posted

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? :dance:

 

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

Posted

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

Posted (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 :dance:

Edited by borfast
Posted

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 :)

Posted

Well, I thought you had your site hosted here at TCH - every server has PHP installed and a lot of other goodies :lol:

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 ;)

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...