Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Background Image Swap Script


16 replies to this topic

#11 t3jem

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 519 posts
  • Gender:Male
  • myCENT:ZERO

Posted 14 November 2007 - 12:14 AM

View Postjlhaslip, on Nov 12 2007, 11:36 PM, said:

Here is another, simpler, method. Serve a different CSS file based on the time of day.
Replace your existing link tag with the following php code.
You will need 3 CSS files named according to the file names used in the script, of course, with the background image changed in each one according to the preferred design.

<?php
 $hour = date('H');
 if ($hour < 12 ) {
	 echo '<link rel="stylesheet" type="text/css" href="morning.css" />;
 }
 elseif ($hour < 17 ) {
	 echo '<link rel="stylesheet" type="text/css" href="day.css" />;
 }
 else {
	 echo '<link rel="stylesheet" type="text/css" href="night.css" />;
 }
 ?>
Untested. No example available.

That is actually the way I do my styles for different times of years, except because I'm too lazy to test on my website i do it in javascript, but it's almost the exact same code. Thanks for the code though, I can see it now.

#12 hippiman

    Premium Member

  • Kontributors
  • PipPipPipPipPipPipPipPip
  • 153 posts
  • Gender:Male
  • Location:Nebraska

Posted 14 November 2007 - 10:45 PM

That's pretty friggin sweet! I didn't know you could name a folder with an extension. I wonder what else you could use that for... :rolleyes:

#13 jlhaslip

    Insert Custom Title Here

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,040 posts
  • Gender:Not Telling
  • Location:Linux, DOS and Windows…the good, the bad and the ugly
  • myCENT:81.07
  • Spam Patrol

Posted 02 January 2008 - 04:02 AM

View Posthippiman, on Nov 14 2007, 03:45 PM, said:

That's pretty friggin sweet! I didn't know you could name a folder with an extension. I wonder what else you could use that for... :)

This technique can also perform Random Image Generators and a Random sig or avatar rotator script.
I have another Tutorial around here on the trap that shows the Random Avatar, I think it is... gif's, png's, jpg's or a combined image script.

http://www.trap17.com/forums/index.php?s=&...st&p=350113

There it is...

#14 Dooga

    Coolio

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPip
  • 1,346 posts
  • Gender:Male
  • Location:Canada
  • Interests:Eating SPAM
  • myCENT:66.95

Posted 02 January 2008 - 11:49 PM

I think this is pretty clever. I saw a lot of professional web designers who actually use the day and night difference, because it makes the site look like a place in real life! It also has sounds that correspond with the time of day. Perhaps that could be your next tutorial when you're bored and want to cook up something else that's as brilliant as this one :)

#15 jlhaslip

    Insert Custom Title Here

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,040 posts
  • Gender:Not Telling
  • Location:Linux, DOS and Windows…the good, the bad and the ugly
  • myCENT:81.07
  • Spam Patrol

Posted 19 July 2008 - 04:37 AM

Attention!!!

Someone sent me an email a few days ago about this script not working for them, and I somehow misfiled or deleted the e-mail, so if you have a question, please PM or email me.

Thanks for your interest in the script.

#16 bad_boy

    Newbie [Level 2]

  • Kontributors
  • PipPip
  • 37 posts

Posted 19 July 2008 - 09:55 AM

Hello everyone,
this right can work in any browser?
Few make this idea but try, I'm nob in the world of web design ... I hope that you will understand and support if something does not know I should be .. Thanks for the code :)

#17 Guest_Seren_*

  • Guests

Posted 17 August 2010 - 05:06 PM

Well hi there...I'm trying to implement this script with random rotation instead of depending on the time of day. I am not very PHP savvy though, so I'm having trouble swapping out the time arguments with a random one that I have from a different rotate.php file I have. I know it can be done; would anyone mind letting me know what I need to swap out and with what arguments? Thanks in advance!




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users