6.x node.pages.inc node_add_page()
7.x node.pages.inc 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.

See also


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


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


function node_add_page() {
  $item = menu_get_item();
  $content = system_admin_menu_block($item);

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


tmsimont’s picture

On the /node/add page, all content types are displayed that the viewing user has permission to create. I created a different page, where I wanted to only show certain content types, even if the viewing user had permissions to create more than what I wanted to show. (I was shooting for better organization of a large number of content types, and also hiding "supplemental" content types that don't make sense to exist on their own as "content" -- I frequently create content types to solve data storage problems, and don't always want the user to see these types when going to the create content landing page)

The below code works to return a list that only contains content types listed in the "show these only" array. Please note that this does not affect permissions. If you don't want a user creating a certain content type, then change the permissions -- this is just for aesthetic reorganization of content type lists.

function custom_administration_add_content_page(){
	//fake out system_admin_menu_block() to get content type links
	$links = system_admin_menu_block(array('path'=>'node/add'));
	//build a list of types to show by content type machine name
	$show_these_only= array(
	//build a new array of reduced items
	foreach($links as $link){
		//get which content type this is from access arguments array
		$args = unserialize($link['access_arguments']);
			$content[] = $link;
	//use the same theme and return
	$output = theme('node_add_list',$content);
	return $output;
tmsimont’s picture

i meant for this to be on d6 page.. from a glance at d7 code it should work there, too -- but beware, it was only tested on d6

ymakux’s picture

In d7

system_admin_menu_block(array('path'=>'node/add', 'tab_root' => 'node/add'));