I need a way to hide a content type on the node add page, or better yet, make two separated node add pages that separate my content types. I'm on Drupal 7 and have four different content types. I would like three of them to be on the default node add page and the fourth to be separate. How would I do this? Thanks
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.
-
Thanks for your answer. Your first possible way is the one I would use because I still need users to be able to create nodes of my fourth content type. I just need it separated from the other three. – oobie11 Dec 16 '11 at 10:31
-
Ok so just move the menu item in another menu or hide it and create another one this the same menu link (node/add/<your_content_type>) – nourcy Dec 16 '11 at 11:24
-
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;
}
}
-
2MENU_DEFAULT_LOCAL_TASK converts the links into tabs. I have used MENU_CALLBACK instead. – Freeman Jul 24 '13 at 10:43
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.
-
Thanks! Where is the
node/add
page located in for me to copy? And how would you suggest printing out the different content types? – oobie11 Dec 16 '11 at 10:34 -
It should be in
node.pages.inc
. If you need the other types to show up as you create them and don't have a static list, do it in code. – wizonesolutions Dec 16 '11 at 20:58 -
Self-follow-up: I don't like my own answer from 4.5 years ago. Use one of the ones above :) – wizonesolutions May 28 '15 at 11:05