Contemplation

Alternating Blog Themes

I should be working on more important things (like my career, for example), but I decided to spend yet more time faffing about and play with some code, meanwhile at least.

I’m not sure if this trick has been documented elsewhere on the web (it probably has), but it was only extended from a “custom greetings” code I learned once (the ‘good morning/evening/night’ one, if you ever came across it). So, I thought I’ll display my header background in a different color (express ‘color overlay’ filter photoshopping) depending on the time of the day. Of course, you can decide to display a whole different theme altogether if you want, but I thought change the header coloring would be subtle and interesting in the same time.

Now, these headers will show depending on the time of the day (GMT+3).

In the morning (0500 - 1159)
Morning Blue Header

In the afternoon (1200 - 1759)
Afternoon Original Header

In the evening/night (1800 - 2359)
Evening/Night Red Header

After midnight ( 0000 - 0459)
After Midnight Yellow Header

Well, there’s nothing to it, all you have to do is write an php function of an ‘if’ statement echoing a different css ‘id’ name (which you will have to write as well) and respectively match both. I’m not going to attempt writing a full tutorial yet (because 1. its not too complicated, and 2. because I haven’t got a proper code highlighting plug-in), but I might do so

So, hopefully you will end up visiting these pages at different times of the day to see the changes. If you do, let me know what you think of it.

7 Comments >>

  1. Lovely idea…but right now none of them is showing.

  2. H.

    What do you mean ‘none of them are showing’? Is it totally blank?? White?

    It’s supposed to be the red one right now -_-’

  3. Just plain black.

  4. Now it’s red. What did you do?

  5. Yep works here :) Cool trick !
    Sometimes the web browser (or Batelco’s proxy) caches the css files so the user doesn’t have to re-download the same content again. This is why changes did not appear immediately to bint battuta. If that happens press [SHIFT] and click on the refresh button. This should force all content to be redownloaded. The black header was shown to me on my first visit but refreshing the cache changed it to the red header. Usually the cache expires in a short while so H. should not worry about it :)

  6. H.

    @BB: didn’t do anything (see Yousif’s comment for the most possible explanation). That’s what it’s supposed to do, change all by its self according to the time of day ;)

    @Yousif: Thanks buddy :D

  7. thats pretty creative. love the idea :)

Reply to “Alternating Blog Themes”