Below is my .module file, when i go to mysite/timeline/nodes there is no display. While what i am planning is to display a timeline . I am new to Drupal (and web development). I have other JS,JSON and PHP file in my module folder too to make the simile timeline script available to the code, if somebody needs to see that please tell. Also i have read that tpl.php provides sometype of solution (i havent read it much so i dont know how it does exactly) but i want to display the regular page theme and put content in the content area when using hook_menu to create a new page.

function similetimeline_menu() {
$modulepath = drupal_get_path('module', 'similetimeline');
drupal_add_js($modulepath . '/similetimeline.js');

$items = array();
$items['timeline/nodes'] = array(
'page callback' => 'similetimeline_callback_nodes',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
$items['timeline/ratings'] = array(
'page callback' => 'similetimeline_callback_ratings',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
return $items;

function similetimeline_callback_nodes() {
$query = new EntityFieldQuery;

$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'article')
  ->propertyCondition('status', 1);

$results = $query->execute();
$output = array();
if (isset($results['node'])) {
$nodes = node_load_multiple(array_keys($results['node']));
foreach ($nodes as $nid => $node) {
  $output[$nid] = array(
    'title' => $node->title,
    'timestamp' => $node->created,
    'body' => $node->body[LANGUAGE_NONE][0]['safe_value'],

global $base_path;
$timeline_lib_path = $base_path . libraries_get_path('simile_timeline');

// Set some global js variables that the library is going to need for proper inclusion and funcionality
$timeline_inline_js = "
var Timeline_ajax_url = '$timeline_lib_path/timeline_ajax/simile-ajax-api.js',
     Timeline_urlPrefix = '$timeline_lib_path/timeline_js/',
     Timeline_parameters = 'bundle=true';
drupal_add_js($timeline_inline_js, array('type' => 'inline', 'weight' => 10));

// Adding general timeline library
drupal_add_js("$timeline_lib_path/timeline_js/timeline-api.js", array('weight' => 11));

$html = '';
$html .= '<div id="my-timeline" style="height: 150px; border: 1px solid #aaa"></div>   <noscript>
 This page uses Javascript to show you a Timeline. Please enable Javascript in your browser to see the full page. Thank you.</noscript>';

 print theme('similetimeline', $html);
 return null;
  • Does one of you other files define a function theme_similetimeline? Do you have a hook_theme that adds it to the registry? While implemeting a theme independant module is great, I would remove the theme() completely to see if just printing the markup directly gives output. – Letharion May 25 '12 at 21:18
  • - Does one of you other files define a function theme_similetimeline? NO - Do you have a hook_theme that adds it to the registry? NO – LivingThing May 25 '12 at 21:25

So continuing from the comments above.

You are calling theme('similetimeline', $html);, which in turn will call theme_similetimeline($html). So the main reason you don't get any output, is simply that you lack the theming function.

To get started, you can do away with theme() all together and just print $html;. Especially since you've already generated the markup, but on the other hand, it's great that you've already gotten far enough to know you should use theme(), considering you say you are a beginner. The reason for theme calls, is that you can separate the module and it's functionality, from it's markup, meaning this timeline can look different in different themes.

You will find a more extensive example, and a great answer by Clive, in a similar question I asked recently.

  • I can only see the DIV element now the drupal part is missing completely... – LivingThing May 25 '12 at 22:13
  • The drupal part also come but most important part i.e the the timeline is not displayed at all.. – LivingThing May 25 '12 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.