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!

Comments

killes@www.drop.org’s picture

Status: Active » Fixed

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.

stijn vanhandsaeme’s picture

Status: Fixed » Postponed (maintainer needs more info)

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!

stijn vanhandsaeme’s picture

can anyone help me with this? thank you.

frank ralf’s picture

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_upcoming you might have a look at http://drupal.kollm.org/doxygen/_contrib/drupal-contrib-phpdoc/group__ev... .

Frank

frank ralf’s picture

Hello,

In addition to your modification of the theming function you have to implement hook_event_edit_upcoming in your module like so (as written in #1):

 /**
 * 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

frank ralf’s picture

Status: Postponed (maintainer needs more info) » Needs work
killes@www.drop.org’s picture

Status: Needs work » Fixed

I think that's enough info, thanks Frank!

frank ralf’s picture

An even simpler solution is using $node->event_start instead of $node->event['timeleft'] in function theme_event_upcoming_item()
(http://www.drupalcenter.de/node/10643)

Frank

stijn vanhandsaeme’s picture

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.

stijn vanhandsaeme’s picture

Status: Fixed » Postponed (maintainer needs more info)

sorry tried to change status to 'need more info'

frank ralf’s picture

The following code does work with my installation when put in template.php. Be sure to name the function according to your theme.

function 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 ;-)

stijn vanhandsaeme’s picture

Status: Postponed (maintainer needs more info) » Fixed

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!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

mokko’s picture

this is good I need to look at it later.

cafuego’s picture

See also the patch at http://drupal.org/node/34271