There currently is no way to prevent a content type from showing up on the node/add page (Create content).

I'm writing a module that programatically creates the content type. But a user/admin shouldn't be able to create a node of this type from node/add/content_type_name.

So, the request is to add a "hidden" option to each content type that determines whether it is visible to users or not. But I'll only work on a patch if there is a chance it will be committed (so let me know!) :-)

Comments

Crell’s picture

I can't guarantee that it would be accepted, but I'd certainly be interested in such a feature for nodereview.module. You can have a look at that for a somewhat hacky way to hide it for now (it's 4.7-based, 5.0 upgrade is forthcoming), but a clean and standard way to do so would be very welcome. +1.

Crell’s picture

Assigned: Unassigned » Crell
ChrisKennedy’s picture

Is it not possible to create a set of permissions for each dynamic content type, like node.module does for custom content types?

RobRoy’s picture

Remember that UID 1 has all permissions so even though he may see it on node/add, if you don't allow anyone else to "create" on Access Control they won't see it. Then, you could still programatically create a node using drupal_execute(). I think...is that what you're looking for?

moonray’s picture

Actually, in my case the node gets created, and linked to a taxonomy term, from the taxonomy term's page: taxonomy/term/34. You should only be able to create it from there, and not from the add node section.

What I did as a work-around is to give a "Not available" message when you try to go to node/add/term. But it would be nicer if it didn't show up under node/add at all.

Crell’s picture

For Drupal 5, have a look at how nodereview does it.

For Drupal 6, let's just get a real toggle checkbox in the system. :-)

Crell’s picture

Status: Active » Needs review
StatusFileSize
new7.58 KB

OK, let's see if anyone bites... Patch attached. Includes a system.module update function. Someone check my postgres syntax, please. :-)

chx’s picture

Assigned: Crell » chx
StatusFileSize
new9.07 KB

Meanwhile, I removed a better half of node_add. Less code but more alterable thanks hook_menu_alter. Yay.

Crell’s picture

Assigned: chx » Crell
StatusFileSize
new8.95 KB

/me steals the issue back from chx. :-)

After some discussion in IRC with chx and the other usual suspects, here's a revised revised version. This one includes chx's addition to make the node/add index cleaner, but instead of just hiding the menu item node types that are not listed there have no callback at all. node/add/foo simply won't exist. If you want to restore the callback, there or elsewhere, you would have to add your own node/add/foo menu callback (or put it someplace else if you prefer) in your own module. Since the code would be the same, the menu entry is all you'd need.

chx’s picture

I thought we agreed on renaming show_in_menu to visible?

Crell’s picture

No, I said that since we weren't switching to a 3-value field I didn't see a need to change "show_" to "visible_". If TPTB really want it, though, it wouldn't be hard to do I guess.

oscnet’s picture

+1 for this, it is what I needed currently .

chx’s picture

After my patch, why stick this to the content type screen, why not just disable in menu.module ? (i have menu item disable working, so it'll be available)

chx’s picture

Title: Hidden Content types? » Simplify node_add; replace the node_add summary with a new style admin page
StatusFileSize
new1.85 KB

Just let the menu system handle it. You want to remove from the menu system totally? hook_menu_alter it out of existence -- just unset it from the menu tree. You can use the upcoming menu module feature -- disable the menu item. Many posisiblities are there. And, it's less code.

chx’s picture

StatusFileSize
new2.37 KB

Spectacularly broken lil' patch, that was.

chx’s picture

StatusFileSize
new2.37 KB

Spectacularly broken lil' patch, that was.

Jaza’s picture

Title: Simplify node_add; replace the node_add summary with a new style admin page » Let the menu system generate the node/add summary page
Status: Needs review » Reviewed & tested by the community

Tested this, and it seems to work great. Except that you get a white screen of death on 'node/add', until you manually call menu_rebuild() - so just do that after applying, and you'll be fine.

Can't remove node types from this page given the current state of HEAD, but Chx assures me that once the menu admin page is back, you'll be able to remove node types from the listing, simply by disabling the menu item for that node type.

+1, I think this can go in.

dries’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new28.99 KB

Looks good, but it doesn't work 100%. When I disable a content type, it is removed from the menu, but not from the overview page. See the screenshot.

Secondly, when I disable the 'story' menu on the menu administration page, it 'sinks' to the bottom, and it gets attached to the wrong parent. It becomes a child of 'logout' on a stock Drupal CVS HEAD install. This second issue might belong in a separate issue, but I figured I'd mention it nonetheless.

dries’s picture

Nevermind, my first bug report (with the screenshot) -- upon closer investigation, it does work as intended. Good stuff, chx! :)

The menu item does loose its parent though.

I've committed the patch, but I'm leaving this as 'code needs work' so we can look at the parent issue -- or move it to another issue.

moonray’s picture

Just read Dries' post #17... does that mean that the patch only disables the item in the menu system, and not from the node/add overview page? Or was that just a glitch in your test environment Dries?

moonray’s picture

Sorry, I meant Dries' post #19.

chx’s picture

Assigned: Crell » chx
Status: Needs work » Reviewed & tested by the community

The parent issue is a) have nothing to do with this issue b) is already fixed, there are known problems with the custom menu items, this being one. Patch expected for that ... soon.

chx’s picture

Status: Reviewed & tested by the community » Fixed

D'oh! I have skipped the 'i committed' part. OK, this issue is fixed. Parents will be elsewhere.

dww’s picture

Status: Fixed » Needs work

shouldn't this get a mention at the 6.x upgrade doc? (http://drupal.org/node/114774). it's developer-visible, right? for example, when upgrading project_release.module to 6.x, i'd certainly take advantage of this fact to finally have a sane solution for the /node/add/project-release problem, if only i knew about it. ;)

chx’s picture

Status: Needs work » Fixed

Doc'd.

Anonymous’s picture

Status: Fixed » Closed (fixed)
summit’s picture

Hi,
Is this patch committed. And does this mean that node/add contenttypes can be made unvisible on "create content" screen?
Greetings, Martijn

robertgarrigos’s picture

I ported this to drupal 5.x with a slightly different approach.