Hi all.

I have a list of upcoming events. I don't use any kind of classification for my events -- they're all of the same type.

Under the Upcoming events block, they're listed like this:

Sample event!
(5 days) (event)

Is there any way to get rid of the useless (event) tag?

Are there any other ways to customize the display -- for example, can I add the actual date of the event instead of either the (5 days) or the (event)? E.g.:

Sample event!
August 1, 2006 at 5:30pm

Thanks for any help!

Comments

hitesh pherwani’s picture

Hello,

Removing the (event) tag can be done in the event module.
In in the event modules dir there is event.theme file in this file there is a line---
Current line
$output .= ''. t("($node->typename)") .''
just comment this line and the tag will be removed.

// $output .= ''. t("($node->typename)") .''

Regards,

Hitesh

gtcaz’s picture

Thanks!

Here's what I ended up doing -- looks much better on my site:

/**
 * Format an individual upcoming event block item
 *
 * @param node
 *   The node to render as an upcoming event
 */
function theme_event_upcoming_item($node) {
  $output = l($node->title, "node/$node->nid", array('title' => $node->title));
//  if ((event_get_types('all') + event_get_types('solo')) > 1) {
//    $output .= '<span class="event-nodetype">'. t("($node->typename)") .'</span>';
//  }
  $output .= '<span class="event-timeleft">('. gmdate('D, F j, Y', $node->event_start) .')</span>';
  return $output;
}
hitesh pherwani’s picture

Can you post your site's link to view the changes.
Even i will consider on changing on my site to

www.ilaaka.com

Regards,

Hitesh

Cromicon’s picture

I've implemented gtcaz's change (thank you all) at www.walkerstalk.com :)

gtcaz’s picture

I forgot to include timezone offsets. My site is always MST (-7) so I hardcoded that in. Slowly trying to hack a better solution. This really needs to be moved into the config panel.

EDIT: I really don't know what's up. In my test box (XAMPP) I the timezone is correct with no adjustment. On my server (set to UTC with the correct offsets set through Drupal) my upcoming events block dates are not adjusted for the offset. Strange.

divrom’s picture

Where did u put that code, gtcaz?

Did u replace your whole event.theme with that?

gtcaz’s picture

No -- just comment our the lines like I did above and add the new formatting line. Better yet, solipsists' example that handles timezones correctly from here: http://drupal.org/node/78271

I think the function is at around line 480.

divrom’s picture

Thanks a lot. Works perfectly.

scottrussell-1’s picture

Is your modification to event.theme working in drupal v4.7.3? I tried it, and no events were displayed. Thanks!

fraew’s picture

this is great; but by any chance can somebody figure out how to group these event items in the upcoming block by the date, rather than displaying the date under each event? i used it for a gig guide, so i have 5+ events most days...

emmajane’s picture

This is a fantastic little snippet. I've modified it to get rid of the year, but apart from that I love it!

lindmar’s picture

That's exactly what I was looking to do.
Thanks

isaac77’s picture

Thank you for this post, it helped me find the relevant code.

I'd suggest OVERRIDING the _theme function instead of commenting out a line in the event module's ".theme" file.

  • Go to the event.theme file in the event module directory.
  • Copy the relevant function to your clipboard:
    function theme_event_upcoming_item($node) {
    $output = l($node->title, "node/$node->nid", array('title' => $node->title));
    
    $output .= '<span class="event-start">('. $node->event_start .')</span>';
    return $output;
    }
  • paste it into the template.php file in your theme's directory
  • rename the function by changing
    function theme_event_upcoming_item($node)
    to function phptemplate_event_upcoming_item($node)
    (Assuming you are using a phptemplate theme. Otherwise, i think you can just use [your-theme's-name]_event_upcoming_item($node)
  • make changes to the code here, instead of in the event.theme file

This way, if you ever have to update the event module code, re-install it, etc you won't lose the modifications.

jorhett’s picture

I'm using the default garland theme. All functions are phptemplate_ prefix. I added the revised functions exactly as you described and it didn't change the display. Only editing events.theme changed the display.

Is there a difference in 5.1 ?

--
Jo Rhett
Net Consonance

Firewolf’s picture

The code is working perfect, except the date format function should be used.

I adapted the code to my needs as follows:

function aurora_event_upcoming_item($node) {
$output = '' . format_date($node->event_start, 'custom', 'd/m/y');
$output .= '
' . l($node->title, "node/$node->nid", array('title' => $node->title));
return $output;
}

Firewolf’s picture

The code is working perfect, except the date format function should be used.

I adapted the code to my needs as follows:

function theme_event_upcoming_item($node) {
$output = '' . format_date($node->event_start, 'custom', 'd/m/y');
$output .= '
' . l($node->title, "node/$node->nid", array('title' => $node->title));
return $output;
}

Firewolf’s picture

Seems some problems with adding the comment properly. Next try for my code:

function theme_event_upcoming_item($node) {
  $output = '<span class="event-start">' . format_date($node->event_start, 'custom', 'd/m/y');
  $output .= '<br></span>' . l($node->title, "node/$node->nid", array('title' => $node->title));
  return $output;
}
artatac’s picture

I have used this and it works well. Unfortunatly the title and time left fields are on seperate lines, wasting space. Could anyone tell me The code is currently
function theme_event_upcoming_item($node) {
$output = l($node->title, "node/$node->nid", array('title' => $node->title));
if ((event_get_types('all') + event_get_types('solo')) > 1) {
}
$output .= '('. $node->timeleft .')';
return $output;
}

gracearoha’s picture

I was able to showing the date of the upcoming events (using event 5.2x-dev using the following

function theme_event_upcoming_item($node) {
$output = l($node->title, "node/$node->nid", array('title' => $node->title));

$output .= '<span class="event-start">('. $node->event_start .')</span>';
return $output;
}

But i would like to show the start date without the time.

Note: The other codes offered above do not work in event 5.2x-dev. It is true that only the date is shown, however, the date reverts to 1/1/70.

Any ideas?

MyZeeland’s picture

I needed to remove (event) from upcoming events, AND the monthly calendar. I found that by changing this (in the event.css file):

.event-calendar div.type {
  margin-left: 5px;
  font-size: 0.8em;
}

to this:

.event-calendar div.type {
  margin-left: 5px;
  font-size: 0.8em;
  display: none;
}

did the trick.