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

killes@www.drop.org - October 26, 2008 - 23:03
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.

#2

yichalal - October 28, 2008 - 08:04
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!

#3

yichalal - November 5, 2008 - 08:54

can anyone help me with this? thank you.

#4

Frank Ralf - November 5, 2008 - 20:40

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

#5

Frank Ralf - November 6, 2008 - 07:41

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):

<?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

Frank Ralf - November 6, 2008 - 07:46
Status:postponed (maintainer needs more info)» needs work

#7

killes@www.drop.org - November 6, 2008 - 09:00
Status:needs work» fixed

I think that's enough info, thanks Frank!

#8

Frank Ralf - November 6, 2008 - 10:33

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

#9

yichalal - November 6, 2008 - 19:36

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

yichalal - November 6, 2008 - 19:39
Status:fixed» postponed (maintainer needs more info)

sorry tried to change status to 'need more info'

#11

Frank Ralf - November 6, 2008 - 20:28

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

<?php
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 ;-)

#12

yichalal - November 7, 2008 - 09:19
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!

#13

System Message - November 21, 2008 - 09:22
Status:fixed» closed

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

#14

mauricemengel - February 7, 2009 - 21:36

this is good I need to look at it later.

#15

cafuego - April 4, 2009 - 00:06

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

 
 

Drupal is a registered trademark of Dries Buytaert.