diff options
| author | Silvio <silvio@socioambiental.org> | 2012-08-02 17:14:28 -0300 | 
|---|---|---|
| committer | Silvio <silvio@socioambiental.org> | 2012-08-02 17:14:28 -0300 | 
| commit | 53454451a84938723f399a4dd0ced569a5b9fa28 (patch) | |
| tree | 96780e66f607c2f93b4d475b1695d5e3cb710050 | |
| parent | 71bc401f1da3c4220ee1edf21e743e3a9f560d01 (diff) | |
| download | timelinejs-53454451a84938723f399a4dd0ced569a5b9fa28.tar.gz timelinejs-53454451a84938723f399a4dd0ced569a5b9fa28.tar.bz2  | |
Adding embed and image fields into the timeline
| -rw-r--r-- | timelinejs.module | 11 | ||||
| -rw-r--r-- | timelinejs_json_event.tpl.php | 16 | 
2 files changed, 18 insertions, 9 deletions
diff --git a/timelinejs.module b/timelinejs.module index da6023f..2e79b4e 100644 --- a/timelinejs.module +++ b/timelinejs.module @@ -90,9 +90,9 @@ function timelinejs_load_events($nid) {   */  function timelinejs_json($nid) {    // Sanitization and basic data. -  $nid   = (int) $nid; -  $node  = node_load($nid); -  $nodes = timelinejs_load_events($nid); +  $nid      = (int) $nid; +  $timeline = node_load($nid); +  $nodes    = timelinejs_load_events($nid);    foreach ($nodes as $node) {      $items[] = node_load($node->entity_id); @@ -103,10 +103,9 @@ function timelinejs_json($nid) {      $events   = implode(',', $output);    } -  // TODO    $text     = $media = NULL; -  $headline = $node->title; -  $date     = $node->field_data['und']['0']['value']; +  $headline = $timeline->title; +  $date     = $timeline->field_data['und']['0']['value'];    print theme('timelinejs_json', array(      'headline' => $headline, diff --git a/timelinejs_json_event.tpl.php b/timelinejs_json_event.tpl.php index a76f806..575017e 100644 --- a/timelinejs_json_event.tpl.php +++ b/timelinejs_json_event.tpl.php @@ -1,11 +1,21 @@              { -                "startDate":"<?php print strftime('%Y,%m,%d,', strtotime($event->field_data['und']['0']['value'])); ?>", +                "startDate":"<?php print strftime('%Y,%m,%d,', strtotime($event->field_data['und'][0]['value'])); ?>",                  "headline":"<?php print $event->title; ?>", -                "text":"<?php print $event->body['und']['0']['value']; ?>", +                "text":"<?php print $event->body['und'][0]['value']; ?>",                  "asset":                  { -                    "media":"<?php // TODO: print $event->media; ?>", +<?php if (!empty($event->field_embed)) { ?> +                    "media":"<?php print file_create_url($event->field_embed['und'][0]['uri']); ?>",                      "credit":"",                      "caption":"" +<?php } else if (!empty($event->field_image)) { ?> +                    "media":"<?php print file_create_url($event->field_image['und'][0]['uri']); ?>", +                    "credit":"", +                    "caption":"" +<?php } else { ?> +                    "media":"", +                    "credit":"", +                    "caption":"" +<?php } ?>                  }              }  | 
