| 6 node.pages.inc | node_add_page() |
| 7 node.pages.inc | node_add_page() |
| 8 node.pages.inc | node_add_page() |
1 string reference to 'node_add_page'
File
- modules/
node/ node.pages.inc, line 18 - Page callbacks for adding, editing, deleting, and revisions management for content.
Code
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);
drupal_goto($item['href']);
}
return theme('node_add_list', array('content' => $content));
}
Login or register to post comments
Comments
reproducing behavior
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.
<?phpfunction 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(
'page',
'content_type_to_show'
);
//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']);
$type=$args[1];
if(in_array($type,$show_these_only)){
$content[] = $link;
}
}
//use the same theme and return
$output = theme('node_add_list',$content);
return $output;
}
?>
d6
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