We use the Events module to manage workshops here in the Teaching & Learning Centre, and use the “Upcoming Events” block to display the next few workshops on our website. Works great, but the default text leaves a bit to be desired. By default, it shows the event title, and “(2 days)” – which indicates that the event begins in 2 days.

But, it could also mean that the event lasts for 2 days.

So, I just added a trivial change to the event.module file, adding the following line of code at line 1847 (on my copy of the file, which was checked out on June 4, 2007):

$timeleft = 'starts in ' . $timeleft;

That changes the text indicator in the “Upcoming Events” block to read:

(starts in 2 days)

Which is much clearer in meaning. Easy peasy. I just have to remember to edit the module after updating, if this doesn’t make it in…

Comments

4 Responses to “Cleaning up the Upcoming Events block in Drupal”

  1. Ben says:

    even better – is to have it use the exact date – check out this post – works beautifully… instead of (15 days) it outputs (11/11/07 – 10:00) – makes much more sense

    http://drupal.org/node/161527

  2. Although it works, it would be better to do this in your theme, instead of in the module code. Remember: Override, don’t change.
    Using PHPTemplate an possible function would be:
    title, “node/$node->nid”, array(’title’ => $node->title));
    if ((count(event_get_types(’all’)) + count(event_get_types(’solo’))) > 1) {
    $output .= ”. t(”($node->typename)”) .”;
    }
    if($node->timeleft != t(’Now’)) {
    $output .= ‘(starts in ‘. $node->timeleft .’)';
    } else {
    $output .= ‘(’. $node->timeleft .’)';
    }
    return $output;
    }
    ?>
    Hope that helps.

    Rolf van de Krol

  3. Hmm, not very usefull, it strips all HTML, but I hope you get the point.

  4. Joe (spammy nickname removed) Peters says:

    I actually prefer it in the “15 days” way – looks less computerized

Leave a Reply