customize upcoming list view
yichalal - October 26, 2008 - 19:25
| Project: | Event |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
hi i'm trying to display the start date in de upcoming list view instead of the 'time left'.
i tried to work with a hook in
function framework_event_upcoming_item($node, $types = array()) {
$output = l($node->title, "node/$node->nid", array('attributes' => array('title' => $node->title)));
if (count($types) > 1) {
$output .= '<span class="event-nodetype">('. $node->event['node_type'] .')</span>';
}
$output .= '<span class="event-timeleft">('. $node->event['timeleft'] .')</span>';
return $output;
}but when i replace 'timeleft' with 'start' or 'start_utc' nothing gets displayed.
also tried to create new view but the i don't get any field with the start date.
any suggestions on any of these ways of solving the problem? thanks!

#1
FOr performance reasons the upcoming events block does not fetch whole nodes, but only sceleton nodes.
If you want full nodes, you need to implekment hook_event_edit_upcoming and do a node_load in there.
#2
i'm sorry but i don't know where to start with what you say. don't have to explain everything i think. just a hint of how to start. thank you very much for your help!
#3
can anyone help me with this? thank you.
#4
Will have a look at it when I find the time. Always wanted the same changes ;-)
(Would be nice to have that as a configurable option in the module.)
For some documentation on implementing
hook_event_edit_upcomingyou might have a look at http://drupal.kollm.org/doxygen/_contrib/drupal-contrib-phpdoc/group__ev... .Frank
#5
Hello,
In addition to your modification of the theming function you have to implement
hook_event_edit_upcomingin your module like so (as written in #1):<?php/**
* Implementation of hook_event_edit_upcoming().
*/
function upcoming_event_event_edit_upcoming(&$node){
$node = node_load($node->nid);
}
?>
That loads the full node object with all the attributes available.
HTH
Frank
#6
#7
I think that's enough info, thanks Frank!
#8
An even simpler solution is using
$node->event_startinstead of$node->event['timeleft']infunction theme_event_upcoming_item()(http://www.drupalcenter.de/node/10643)
Frank
#9
ok thank you very much.
this code works when applid in event.theme
function theme_event_upcoming_item($node, $types = array()) {$output = '<span class="date">'.date('d.m.Y', strtotime($node->event_start)) .': </span><br />'.l($node->title, "node/$node->nid", array('attributes' => array('title' => $node->title)));
if (count($types) > 1) {
$output .= '<span class="event-nodetype">('. $node->event['node_type'] .')</span>';
}
return $output;
}
but this code does not work in template.php (changes don't apply although i cleared cache)
function framework_event_upcoming_item($node, $types = array()) {$output = '<span class="date">'.date('d.m.Y', strtotime($node->event_start)) .': </span><br />'.l($node->title, "node/$node->nid", array('attributes' => array('title' => $node->title)));
if (count($types) > 1) {
$output .= '<span class="event-nodetype">('. $node->event['node_type'] .')</span>';
}
return $output;
}
and ireally don't see why it would not work. i'd rather not hack the module files.
#10
sorry tried to change status to 'need more info'
#11
The following code does work with my installation when put in template.php. Be sure to name the function according to your theme.
<?phpfunction YOURTHEME_event_upcoming_item($node, $types = array()) {
// Set locale
setlocale(LC_TIME, 'de_DE');
$output = l($node->title, "node/$node->nid", array('attributes' => array('title' => $node->title)));
if (count($types) > 1) {
$output .= '<span class="event-nodetype">('. $node->event['node_type'] .')</span>';
}
$output .= '<span class="event-timeleft"> '. strftime('%e. %b. | %a.', strtotime($node->event_start)) .'</span>';
return $output;
}
?>
You might also have a look at Can't seem to theme the events module output http://drupal.org/node/306497.
And if you are working with a subtheme of Garland you should read Garland overrides template with theme function http://drupal.org/node/295895 (might be a theme related problem).
HTH
Frank
PS:
Using
<?php ... ?>instead of<code>improves readability of your code snippets ;-)#12
i upgraded my theme (framework-garland based?) and rebuilt the layout. now it works (code i gave above works too), though i don't know what gave the error.
very much thanks everyone!
#13
Automatically closed -- issue fixed for two weeks with no activity.
#14
this is good I need to look at it later.
#15
See also the patch at http://drupal.org/node/34271