💾 Archived View for chirale.org › 2009-12-07_375.gmi captured on 2024-06-16 at 12:37:15. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-12)

-=-=-=-=-=-=-

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.

on

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>