Drupal - How to hide a content type on the node add page?
Two possibilities:
admin/structure/menu/manage/navigation
move/delete menu item that you don't want.- Cleanest way: use roles and permissions. If the user can't create a content type the link will not appear in any menu.
Put this in a custom module:
function yourcustommodule_menu_alter(&$items) {
if (isset($items['node/add/your-content-type'])) {
$items['node/add/your-content-type']['type'] = MENU_DEFAULT_LOCAL_TASK;
}
}
UPDATE
MENU_CALLBACK
, as suggested in other answers, didn't work for me here. They still appear on the node/add
page.
This code worked:
function MYMODULE_menu_alter(&$items) {
if (isset($items['node/add/your-content-type'])) {
unset($items['node/add/your-content-type']);
}
}
Of course, it assumes you want to disable (not hide) the node/add
link for that type.
ORIGINAL ANSWER
The node/add
page is provided by the Node module. You might be able to do what you want by disabling the menu item in the Navigation menu, according to this post: http://data.agaric.com/disabling-or-moving-nodeaddcontent-type-links-from-beneath-add-content-navigation-menu-also-removes
It's a bit of a bug, so it might not be a reliable way to do it. Personally, I'd create a custom version of the node/add
page in a module by copying the existing one and making my specific modifications. Then I would use hook_menu_alter
to make node/add
go to my version.
You might be able to replace it with a view or panel instead (with Page Manager), but I haven't tried this, and you'd probably lose the automation.