1 node_example.module node_example_page()

Callback that builds our content and returns it to the browser.

This callback comes from hook_menu().

Return value

array: A renderable array showing a list of our nodes.

See also




Related topics


modules/examples/node_example/node_example.module, line 140
Module file for Node Example module.


function node_example_page() {
  // We'll start building a renderable array that will be our page.
  // For now we just declare the array.
  $renderable_array = array();
  // We query the database and find all of the nodes for the type we defined.
  $sql = 'SELECT nid FROM {node} n WHERE n.type = :type AND n.status = :status';
  $result = db_query($sql, 
    ':type' => 'node_example',
    ':status' => 1,
  $renderable_array['explanation'] = array(
    '#markup' => t("Node Example nodes you've created will be displayed here. Note that the color fields will be displayed differently in this list, than if you view the node normally. Click on the node title to see the difference. This is a result of using our 'example_node_list' node view type."),
  // Loop through each of our node_example nodes and instruct node_view
  // to use our "example_node_list" view.
  // http://api.DOCUMENTATION_PENDING/api/function/node_load/7
  // http://api.DOCUMENTATION_PENDING/api/function/node_view/7
  foreach ($result as $row) {
    $node = node_load($row->nid);
    $renderable_array['node_list'][] = node_view($node, 'example_node_list');
  return $renderable_array;