diff options
author | Silvio <silvio@socioambiental.org> | 2012-08-01 16:26:32 -0300 |
---|---|---|
committer | Silvio <silvio@socioambiental.org> | 2012-08-01 16:26:32 -0300 |
commit | b0fe5cb2bec5ce8c983530dceb1ec77f5720d656 (patch) | |
tree | fab773e1a028e5e51d380691623dd5ca4b03cf37 | |
parent | a820ecec5069f6670fc3ea45c29657390668e1f5 (diff) | |
download | timelinejs-b0fe5cb2bec5ce8c983530dceb1ec77f5720d656.tar.gz timelinejs-b0fe5cb2bec5ce8c983530dceb1ec77f5720d656.tar.bz2 |
Spliting json template
-rw-r--r-- | timelinejs.module | 19 | ||||
-rw-r--r-- | timelinejs_json.tpl.php | 26 | ||||
-rw-r--r-- | timelinejs_json_event.tpl.php | 18 |
3 files changed, 33 insertions, 30 deletions
diff --git a/timelinejs.module b/timelinejs.module index a49c04f..9ae7f80 100644 --- a/timelinejs.module +++ b/timelinejs.module @@ -79,6 +79,10 @@ function timelinejs_theme($existing, $type, $theme, $path) { 'template' => 'timelinejs_json', 'variables' => array('headline', 'date', 'text', 'media', 'events'), ), + 'timelinejs_json_event' => array( + 'template' => 'timelinejs_json_event', + 'variables' => array('event'), + ), ); } @@ -106,15 +110,21 @@ function timelinejs_load_events($nid) { */ function timelinejs_json($nid) { // Sanitization and basic data. - $nid = (int) $nid; - $events = timelinejs_load_events($nid); + $nid = (int) $nid; + $nodes = timelinejs_load_events($nid); + $items = array(); + + foreach ($items as $event) { + $events[] = theme('timelinejs_json_event', array('event' => $event)); + $events = implode(',', $events); + } print theme('timelinejs_json', array( 'headline' => $headline, 'date' => $date, 'text' => $text, 'media' => $media, - 'events' => array(), + 'events' => $events, )); # Avoid themable output. @@ -123,14 +133,13 @@ function timelinejs_json($nid) { /** * Menu callback. - * - * @todo */ function timelinejs($nid) { return theme('timelinejs', array( 'width' => '960px', 'height' => '500px', 'source' => '/sites/boletim/files/timeline-saude-indigena_2.json', + //'source' => '/timelinejs/json/'. (int) $nid, 'css' => '/sites/boletim/themes/boletimclean/timeline.css' )); } diff --git a/timelinejs_json.tpl.php b/timelinejs_json.tpl.php index 68cfcbb..2e69e8d 100644 --- a/timelinejs_json.tpl.php +++ b/timelinejs_json.tpl.php @@ -1,23 +1,3 @@ -<?php - - global $base_url; - -?> -{ - "timeline": - { - "headline":"<?php print $headline; ?>", - "type":"default", - "startDate":"<?php print $date; ?>", - "text":"<?php print $text; ?>", - "asset": - { - "media":"<?php print $media; ?>", - "credit":"", - "caption":"" - }, -<?php foreach ($events as $event) { ?> - "date": [ { "startDate":"<?php print $event['date']; ?>", "headline":"<?php print $event['headline']; ?>", @@ -28,8 +8,4 @@ "credit":"", "caption":"" } - }, - ] -<?php } ?> - } -} + } diff --git a/timelinejs_json_event.tpl.php b/timelinejs_json_event.tpl.php new file mode 100644 index 0000000..92ac391 --- /dev/null +++ b/timelinejs_json_event.tpl.php @@ -0,0 +1,18 @@ +{ + "timeline": + { + "headline":"<?php print $headline; ?>", + "type":"default", + "startDate":"<?php print $date; ?>", + "text":"<?php print $text; ?>", + "asset": + { + "media":"<?php print $media; ?>", + "credit":"", + "caption":"" + }, + "date": [ +<?php print $events; ?> + ] + } +} |