Automatic Styleswitcher
Posted: 07 June 2008 07:34 AM   [ Ignore ]  
Grad Student
Rank
Total Posts:  100
Joined  11-26-2007

Hi,
does anyone have an idea of how to build an automatic styleswitcher? I want different stylesheets to be loaded according to the time of the day.

Thanks,
Max

Profile
 
 
Posted: 07 June 2008 08:41 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15368
Joined  05-15-2004

Just use an EE template as stylesheet (meaning: don’t use {stylesheet=}) and a few conditionals based on {current_time}. Let’s see:

{if "{current_time format="%H"}" > 6 && "{current_time format="%H"}" < 12}
   
@import url("morning.css");
{if:elseif "{current_time format="%H"}" < 18}
   
@import url("afternoon.css");
{if:elseif "{current_time format="%H"}" < 22 }
   
@import url("evening.css");
{if:else}
   
@import url("night.css");
{/if}

@import url("common.css");

Makes sense? Untested, but should work.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 07 June 2008 08:43 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  100
Joined  11-26-2007

Hi,
yeh understood. Gonna try it out. Actually a good way to hide CSS from undesired browsers aswell. Will post result. Thanks Ingmar!

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64906 Total Logged-in Users: 37
Total Topics: 81851 Total Anonymous Users: 29
Total Replies: 440054 Total Guests: 250
Total Posts: 521905    
Members ( View Memberlist )