Programmatically set the defaults for a new content type
When programmatically creating a new content type I would like to set the default publishing options, comment settings and upload settings, as the content type is installed, so I create a dot install file for the content type with the following:
function custom_module_install() {
// Disable promote to front // Read http://api.drupal.org/api/function/node_object_prepare/6 // could be variable_set('node_options_'. $node->type, array('status', 'promote')); variable_set("node_options_my_content_type", array('status'));
// Disable attachments
// Read http://api.drupal.org/api/function/upload_nodeapi/6 on "load"
variable_set("upload_my_content_type", 0);
// Disable promote to front for this content type
// Read http://api.drupal.org/api/function/comment_form_alter/6
variable_set('comment_my_content_type', COMMENT_NODE_DISABLED);
// Install schema as usual (if any)
drupal_install_schema('custom_module');
}
I want to give a nod to chirale and his article: http://chirale.wordpress.com/2009/12/07/disable-upload-and-comment-for-a-new-content-type-programmatically/ for the heads up on where to look to get this sorted.
Comments
jijo (not verified)
Thu, 21/11/2013 - 06:26
Permalink
Thanks for sharing the code
Thanks for sharing the code for creating a dot install file for the content type! Before trying this code, I want to learn more about this content type and its features! Please share a document explaining the importance and features of content type in the coming days!