Programmatically Switch Themes

Permalink
I'm interested in having a day and a night theme depending on the server time. I don't even know where to start, but I figured it would be nice to have separate themes for ease of editing etc. I'm pretty sure I could do it with php within a single theme, but was interested to know if anyone else has had success programmatically switching themes.

guythomas
 
ScottC replied on at Permalink Reply
ScottC
you'd want to if in your theme based on the strtotime hour range you'd want, which i don't know the date format value off the top of my head for 24 hour stuff instead of switching am/pm. Could google it but whatever.

so $hourTime

if($hourTime < $morning || $hourTime > $night){
night time int css include
}else{
day code
}
guythomas replied on at Permalink Best Answer Reply
guythomas
Just in case anyone else wants to do this.. I decided it would be much simplier to just create an additional "night" css file that changes the graphics etc and embed it into the existing theme.

Here is the code I used..

<style type="text/css" media="screen">
@import "<?php echo $this->getStyleSheet('main.css')?>";
  <?php $time = date("H");
  if ($time > 19 || $time < 6) { ?> 
@import "<?php echo $this->getStyleSheet('night.css')?>";
<?php } ?>
</style>


My site is local community based, so I am simply using the servers time, you may need additional code to use the visitors time.