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

Clock extension?

I don't entirely understand the whole extension system yet, would anyone be interested in writing a simple clock extension that would show up at the bottom of the control panel? I need to display GMT time on my forums for deadlines and such, and right now we're all just kind of guessing in our heads.

Comments

  • Options
    look at the bottom right hand corner of your screen. If it's not GMT, move to the uk :D
  • Options
    MarkMark Vanilla Staff
    Hardy Har Har

    It's not too difficult, I'll write it up and post it here in a few minutes.
  • Options
    edited January 2006
    /me bows and goes for a coffee
  • Options
    MarkMark Vanilla Staff
    edited January 2006
    Note that this code is for Vanilla 0.9.3:

    <?php /* Extension Name: Clock Extension Url: http://lussumo.com/docs/ Description: Adds a clock to the control panel. Version: 1.0 Author: Mark O'Sullivan Author Url: http://markosullivan.ca/ */ if (in_array($Context->SelfUrl, array("account.php", "categories.php", "comments.php", "index.php", "post.php", "search.php"))) { $Time = time(); $GMT = date('Y-m-d H:i:s', ($Time + date("Z", $Time))); $Panel->AddString('<div style="padding: 0px; margin: 0px; text-align: center; color: #aaaaaa;">' .$GMT .'</div>' , 500); } ?>

    If you were going to try to do this in 0.9.2, you'd need to remove that ", 500" at the end of the AddString method.

    Note that the time is formatted using php's date function. Refer to that link if you want the time formatted in some other way.

    To make an extension out of that code, just create a file called Clock.php in your extensions directory, and paste that code into it. Then sign into vanilla as an administrator, go to settings > manage extensions, and enable it.
  • Options
    edited January 2006
    And it's that simple. Maybe i'll have a go at something myself just for fun. (that honestly wasnt sarcasm. I can see how it could be interpreted)
  • Options
    Thanks a lot mark, much appreciated.
  • Options
    NickENickE New
    edited January 2006
    You know, it'd be easier to just use the gmdate() function.
  • Options
    MarkMark Vanilla Staff
    Hahahaha - I didn't know that function existed.

    *slaps forehead*
  • Options
    Neither did I, thanks for the heads up SirNot.
  • Options
    This is just a little update I did my forums, just in case someone else was looking for something like this

    <? if (in_array($Context->SelfUrl, array("account.php", "categories.php", "comments.php", "index.php", "post.php", "search.php"))) { $GMT = gmdate('l H:i (g:i a)'); $Panel->AddString('<div style="padding: 0px; margin: 0px;"><h2>Forum Time</h2><span style="margin-left: 2px;">' .$GMT .'</span></div>'); } ?>
  • Options
    Why the extra variable?
  • Options
    edited January 2006
    <?php if (in_array($Context->SelfUrl, array("account.php", "categories.php", "comments.php", "index.php", "post.php", "search.php"))) { $Panel->AddString('<div style="padding: 0px; margin: 0px;"><h2>Forum Time (GMT)</h2><span style="margin-left: 2px;">' .$GMT = gmdate('l H:i (g:i a)') .'</span></div>'); } ?>

    There we go.
  • Options
    NickENickE New
    edited January 2006
    But you still have that variable...
    <?php
    
    if(@$Panel)
    {
    	$Panel->AddString('<div style="padding: 0px; margin: 0px;"><h2>Forum Time (GMT)</h2><span style="margin-left: 2px;">'
    	.gmdate('l H:i (g:i a)').'</span></div>');
    }
    
    ?>
  • Options
    Gotta plead ignorance here, the level of php this stuff does is way over my head. Thanks for the update :)
This discussion has been closed.