summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--timelinejs.module11
-rw-r--r--timelinejs_json_event.tpl.php16
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 } ?>
}
}