Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Change style based on time/date?

edited February 2007 in Vanilla 1.0 Help
I'd like to automagically switch to a darker theme at night. Is this possible?

Comments

  • Options
    Bump.. I posted this a couple of months ago, perhaps someone has an idea of how to achieve this. After this bump I will leave it alone :)
  • Options
    This would require an extension, which I have no idea how to create. But you also need to kind in mind that since most fora (?) are global, the extension will need to understand people's local time settings, otherwise it will be pretty weird having the style (or theme) change to a night time theme when it's the middle of the day!

    I do think this would be a pretty cool extension for the community however, so I'm going to bookmark this discussion for future reference.
  • Options
    ummmm, might try and knock something up tomorrow will keep you posted.
  • Options
    edited February 2007
    Let me know how you progress with this time-check. I am also working on doing a time-check in a new extension I am working on. I'm trying to use gmt time.

    Edit: I did get my function to work using the date(). Here is my code:
    function check_time(&$Context) { global $compare_time; $compare_time = ""; if (file_exists($Context->Dictionary["GRAPH_FILE"])) { $compare_time = date ("Y-m-d H:i:s", filemtime($Context->Dictionary["GRAPH_FILE"])); list($year, $month, $day, $hour, $minute, $second ) = sscanf($compare_time, "%d-%d-%d %d:%d:%d"); $thatdate = mktime( $hour, $minute, $second, $month, $day, $year ); $now = date("Y-m-d H:i:s",time()); // echo $now."-".TimeAgo($thatdate); $timeparts = explode(' ',$compare_time); $strt = $timeparts[1]; $starttime = $strt.substr($timeparts[0],1); $timeparts = explode(' ',$now); $endt = $timeparts[1]; $endtime = $endt.substr($timeparts[0],1); $diff = $endtime - $starttime; // echo $strt."-".$endt."--- ".$diff." ***"; if ($diff > $Context->Dictionary["GRAPH_TIME"]) return true; return false; } return false; }
    I'm generating an image file, but only want to do it once a day (at midnight). I'm using the timestamp on the image file to compare against. If it's older than 23 hours, then I will regenerate the image file. If anyone sees any problems with this, please let me know.
This discussion has been closed.