summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--timelinejs.module19
-rw-r--r--timelinejs_json.tpl.php26
-rw-r--r--timelinejs_json_event.tpl.php18
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; ?>
+ ]
+ }
+}