I need the default value for enabling/disabling Disqus on the content type.
The attached patch:
* adds a default value to the content type (in the comment vertical tab).
* content type's default value is used when creating the node edit form (instead of the current hardcoded value, TRUE).

PS: I have also cleaned up a little, replacing the hook_form_alter implementation with two hook_form_FORM_ID_alter implementations.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

slashrsm’s picture

Status: Active » Needs work
  1. +++ b/disqus.module
    @@ -731,51 +731,94 @@ function _disqus_block_content($function, $options) {
    +        '#attached' => array(
    +          'js' => array(drupal_get_path('module', 'disqus') . '/disqus-node-type-form.js'),
    +        ),
    +      );
    

    This JS file should be included in the patch.

  2. +++ b/disqus.module
    @@ -731,51 +731,94 @@ function _disqus_block_content($function, $options) {
    +      '#description' => t('Users can post comments using <a href="@disqus">Disqus</a>.', array('@disqus' => 'http://disqus.com')),
    +      '#default_value' => variable_get('disqus_default_status_' . $form['#node_type']->type, TRUE),
    +      '#access' => user_access('toggle disqus comments'),
    +    );
    

    Why not use disqus_nodetypes to save this?

randallknutson’s picture

Not being the original author I'm not sure what the javascript file did but it isn't necessary. I've removed it from my patch.

The reason that disqus_nodetypes is not used is that this isn't about allowing or not allowing disqus comments on a content type as that config variable does. It is for setting the default status of disqus on content types where comments ARE allowed.

For example, we need to allow comments on the blog content type but default them to off. Unless someone with permission turns them on then they should be off.

Patch attached with the following changes:

  1. Removed references to non-existant javascript file.
  2. Reworked the wording on the options to differentiate between them.
randallknutson’s picture

Status: Needs work » Needs review
slashrsm’s picture

Status: Needs review » Needs work

Attached JS file was probably updating summary in vertical tab. It would be nice to have that feature. Otherwise looks good.