From b0fe5cb2bec5ce8c983530dceb1ec77f5720d656 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 1 Aug 2012 16:26:32 -0300 Subject: Spliting json template --- timelinejs.module | 19 ++++++++++++++----- timelinejs_json.tpl.php | 26 +------------------------- timelinejs_json_event.tpl.php | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+), 30 deletions(-) create mode 100644 timelinejs_json_event.tpl.php 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 @@ - -{ - "timeline": - { - "headline":"", - "type":"default", - "startDate":"", - "text":"", - "asset": - { - "media":"", - "credit":"", - "caption":"" - }, - - "date": [ { "startDate":"", "headline":"", @@ -28,8 +8,4 @@ "credit":"", "caption":"" } - }, - ] - - } -} + } 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":"", + "type":"default", + "startDate":"", + "text":"", + "asset": + { + "media":"", + "credit":"", + "caption":"" + }, + "date": [ + + ] + } +} -- cgit v1.2.3