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 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'timelinejs.module') 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' )); } -- cgit v1.2.3