Disable upload and comment for a new content type programmatically
Following code is useful when installing a module that create a new content type programmatically on Drupal x.
Basically, it adds two variables setting default values for comments (core Comment module) and attachments (core Upload module).
Code to write on my_funny_module/my_funny_module.install.
function my_funny_module_install() { // Disable attachments // Read http://api.drupal.org/api/function/upload_nodeapi/6 on "load" variable_set("upload_my_content_type", 0); // Disable comments 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('my_funny_module'); }
Note that this code assign only default values for my_content_type: as any content type, this value could be later changed via GUI.
variable_set('comment_<em>my_content_type</em>', COMMENT_NODE_DISABLED); // Install schema as usual (if any) drupal_install_schema('my_funny_module'); }</pre> <p>Note that this code assign only <em>default</em> values for <em>my_content_type</em>: as any content type, this value could be later changed via GUI.</p> (https://web.archive.org)
Response: 20 (Success), text/gemini
| Original URL | gemini://chirale.org/2009-12-07_375.gmi |
|---|---|
| Status Code | 20 (Success) |
| Content-Type | text/gemini; charset=utf-8 |