function node_add

You are here

7 node.pages.inc node_add($type)
4.6 node.module node_add($type)
4.7 node.module node_add($type)
5 node.module node_add($type = NULL)
6 node.pages.inc node_add($type)

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;
}