How to pass multiple objects to hook_view()? I want my hook_view($node) to display not only the $node, but other fancy stuff too - like a table on the bottom using a while-statement. How can I do this?

I am only able to pass one object to hook_view() so I am limited to one object for output? For example:

function Mymodule_load($node) {
  $sql = "SELECT colors FROM ctable,node WHERE ctable.nid=node.nid";
  //returns lots of color (e.g. blue, red, green, pink)
  $result = db_query($sql);
  //here's where I am stuck!
  while($row = db_fetch_object($result)) {
    return $row;  //oh noes! $row keeps getting overwritten
                  //and all my colors aren't being passed to hook_view
  }
}

function Mymodule_view($node,$teaser=false,$page=false) {
  node_prepare($node,$teaser);
  $node-&gt;content['colors'] = array(
    // only can display ONE color.
    '#value' =&gt; $node-&gt;colors
  )
  return $node;
}


The above code returns only ONE color whereas I want ALL my colors to be passed to hook_view().

THE SOLUTION:

while($row = db_fetch_object($result)) {
  $colors[] = $row-&gt;colors;
}
$node-&gt;colors = $colors;
return $node;
hook_load() gives you the node that was just loaded. The reason it gives you the node is so that you can modify it. So you'd do something like $node->myModule['colors'] = array ( some colors here... ); Read up on the API documentation.

See also the API docs for hook_view().

If you move on to Drupal 7, you can do all this stuff as fields. :-)