I'm struggling a bit to get my head around the render array stuff - what I'm trying to do is have a page callback that displays a node with some additional information. From what I've been reading it seems I should be able to just include the node in the render array that my callback returns but it only shows the node's title and not any of the other fields.

My code is basically this:

function mymodule_test_view($nid) {
  $node = node_load($nid);
  return array(
    'content' => array(
      'node' => array (
        '#theme' => 'node',
        '#node' => $node,
        '#view_mode' => 'full',
      ),
      'text' => array(
        '#markup' => 'This is a test',
      ),
    ),
  );
}

This gets me the title of the node (as a link to the node page) and my test text - what do I need to do to get the fields of the node displayed?

Comments

Web Assistant’s picture

You need to use node_view(), like this:

<?php
function mymodule_test_view($nid) {
  $node = node_view(node_load($nid));
  return array(
    'content' => array(
      'node' => $node,
      'text' => array(
        '#markup' => 'This is a test',
      ),
    ),
  );
}
?>