From a820ecec5069f6670fc3ea45c29657390668e1f5 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 1 Aug 2012 16:08:59 -0300 Subject: Adding timeline output to full node view --- timelinejs.module | 39 +++++++++++++++++++++++++++++++++------ timelinejs.tpl.php | 16 ++++++++-------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/timelinejs.module b/timelinejs.module index c42397d..a49c04f 100644 --- a/timelinejs.module +++ b/timelinejs.module @@ -25,14 +25,19 @@ function timelinejs_field_info() { /** * Implements hook_node_view(). - * - * @todo */ function timelinejs_node_view($node, $view_mode, $langcode) { if ($node->type == 'timeline' && $view_mode == 'full') { + $node->content['timeline']['#markup'] = timelinejs($node->nid); } } +/** + * Implements hook_node_view_alter. + */ +function timelinejs_node_view_alter(&$build) { +} + /** * Implements hook_menu() */ @@ -59,11 +64,20 @@ function timelinejs_theme($existing, $type, $theme, $path) { return array( 'timelinejs' => array( 'template' => 'timelinejs', - 'variables' => array('timeline'), + 'variables' => array( + 'width' => NULL, + 'height' => NULL, + 'source' => NULL, + 'start_at_end' => 'false', + 'hash_bookmark' => 'true', + 'css' => NULL, + 'js' => '/sites/all/libraries/timelinejs/compiled/js/timeline.js', + 'lang' => '/sites/all/libraries/timelinejs/compiled/js/locale/pt-br.js', + ), ), 'timelinejs_json' => array( 'template' => 'timelinejs_json', - 'variables' => array('timeline'), + 'variables' => array('headline', 'date', 'text', 'media', 'events'), ), ); } @@ -95,8 +109,15 @@ function timelinejs_json($nid) { $nid = (int) $nid; $events = timelinejs_load_events($nid); + print theme('timelinejs_json', array( + 'headline' => $headline, + 'date' => $date, + 'text' => $text, + 'media' => $media, + 'events' => array(), + )); + # Avoid themable output. - print theme('timelinejs', array('timeline' => array())); exit; } @@ -105,5 +126,11 @@ function timelinejs_json($nid) { * * @todo */ -function timelinejs($path) { +function timelinejs($nid) { + return theme('timelinejs', array( + 'width' => '960px', + 'height' => '500px', + 'source' => '/sites/boletim/files/timeline-saude-indigena_2.json', + 'css' => '/sites/boletim/themes/boletimclean/timeline.css' + )); } diff --git a/timelinejs.tpl.php b/timelinejs.tpl.php index 0c1004a..1dc3aed 100644 --- a/timelinejs.tpl.php +++ b/timelinejs.tpl.php @@ -2,14 +2,14 @@
-- cgit v1.2.3