Page callback: Displays add content links for available content types.
Redirects to node/add/[type] if only one content type is available.
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.
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,
);
}