Same name and namespace in other branches
  1. 4.6.x modules/node.module \node_add()
  2. 4.7.x modules/node.module \node_add()
  3. 5.x modules/node/node.module \node_add()
  4. 7.x modules/node/node.pages.inc \node_add()

Present a node submission form or a set of links to such forms.

1 string reference to 'node_add'
node_menu in modules/node/node.module
Implementation of hook_menu().

File

modules/node/node.pages.inc, line 49
Page callbacks for adding, editing, deleting, and revisions management for content.

Code

function node_add($type) {
  global $user;
  $types = node_get_types();
  $type = isset($type) ? str_replace('-', '_', $type) : NULL;

  // If a node type has been specified, validate its existence.
  if (isset($types[$type]) && node_access('create', $type)) {

    // Initialize settings:
    $node = array(
      'uid' => $user->uid,
      'name' => isset($user->name) ? $user->name : '',
      'type' => $type,
      'language' => '',
    );
    drupal_set_title(t('Create @name', array(
      '@name' => $types[$type]->name,
    )));
    $output = drupal_get_form($type . '_node_form', $node);
  }
  return $output;
}