9

I am currently creating a small Drupal 7 website, but I don't plan to use the delivered Article content type. Is it possible to disable it without deleting it? What I mean by that is making sure no user will create articles by accident.

I could not find an option for this. Thanks.

17
  • You can't disable a content type, but you can prevent (almost) everyone from creating/viewing/modifying etc. an Article it with setting the permissions accordingly.
  • If there's no Article content on the site, it's 100% safe to delete it. (It's interesting to check out how the default and minimal installation profile provide different sets of content types. Article is just a "stock" content type which is by no means necessary to have.)
7

For people not familiar with Drupal, you would prevent people from using a content type by going (in 7) People > Permissions (url: admin/people/permissions)

Then under Node unchecking the Article: Create new content permission for the selected roles. :)

Obviously you would change Article to the relevant content type.

2
  • Can you think of any reason why a user would still be able to access the "create" link for a particular content type, even though their role disallows creation of that content type? I clones my admin user role, and created an "admin-lite" user role that should only have access to create a handful of the many content types on my site. However, those admin-lite users can create all of the different content types... I tried rebuilding permissions, but that did not help either. – hockey2112 Jan 4 '13 at 17:46
  • 2
    I figured out my issue... the role still had "Bypass Content Access Control" permission enabled. I disabled that, and it fixed my issue. – hockey2112 Jan 4 '13 at 17:53
5

In your .install file:

function YOURMODULE_disable() {

  // Disable content type MyContentType
  disable_content_type('MyContentType');


  //Activation message
  drupal_set_message(t('MyContentType is now disabled on your site.'));
}

and now in your .module or .inc file:

function disable_content_type($type) {
  $type_info = node_type_load($type);
  $type_info->module = 'node';
  $type_info->custom = 1;
  $type_info->modified = 1;
  $type_info->locked = 0;
  $type_info->disabled = 1;
  node_type_save($type_info);
}
2
  • Does this effectively make the node type, and any content of that type, invisible? My use case is an option in the module that would require new content types, but only if that option is selected. I don't want them to see the content type if they don't choose that option, but I also want to keep the integrity of the data if they flip the option on/off/on/etc. – UnsettlingTrend Aug 25 '15 at 20:26
  • @UnsettlingTrend yes. I had a similar need and tried this option. I also had to create an _enable() function in my .install file that called enable_content_type('MyContentType'). In the .module (or .inc) file, $type_info->disabled is set to 0. That way, when the module is enabled, the content type is available. When the module is disabled, the content type is not available. If you need access to the content (e.g. as an admin), you may want to consider another option that changes the permissions for the content type. That was the route I ended up going. – sho May 2 '17 at 2:44
1

You can also try the Content Access module to restrict users based on role to a content type. http://drupal.org/project/content_access

1

There are some content types that can be "disabled" by virtue of disabling the module that uses it. For example: the poll, forum, book and blog content types disappear from the available types when you disable the associated modules. Basic page and article are the two exceptions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.