function node_add_page

Page callback: Displays add content links for available content types.

Redirects to node/add/[type] if only one content type is available.

Return value

array A render array for a list of the node types that can be added; however, if there is only one node type defined for the site, the function redirects to the node add page for that one node type and does not return at all.

See also

node_menu()

1 string reference to 'node_add_page'
node_menu in drupal/core/modules/node/node.module
Implements hook_menu().

File

drupal/core/modules/node/node.pages.inc, line 26
Callbacks for adding, editing, and deleting content and managing revisions.

Code

function node_add_page() {
  $content = array();

  // Only use node types the user has access to.
  foreach (node_type_get_types() as $type) {
    if (node_hook($type->type, 'form') && node_access('create', $type->type)) {
      $content[$type->type] = $type;
    }
  }

  // Bypass the node/add listing if only one content type is available.
  if (count($content) == 1) {
    $type = array_shift($content);
    drupal_goto('node/add/' . $type->type);
  }
  return array(
    '#theme' => 'node_add_list',
    '#content' => $content,
  );
}