Like the comment module, allow comments to be toggled for every individual node who's node type has Disqus enabled.

Files: 

Comments

czarphanguye’s picture

I also have this feature request and also on a node type bases. (For example, no disqus comments on quote nodes.)

wmostrey’s picture

It is already possible to enable/disable Disqus comments per content type but I echo the original poster's request to be able to do this on a node-per-node base in the same way that the core comment module allows for this.

xerexes’s picture

Yeah I have a lot of older content I have moved to read only for comments and since switching to DISQUS all of those nodes are open to commenting again. I'd like an ability to use DISQUS only going forward - this might be hackable actually (I just need to set it for a certain value of node in the DB and up I think) but it would be nice to have it in the admin. I would imagine a lot of people would have my concern with switching to a new comment system.

kevinquillen’s picture

Is there a way to disable Disqus on user pages? It is throwing a JS error.

basvredeling’s picture

Having this as an option in the module would be very helpful.
+1

RobLoach’s picture

Kevin: I believe you can find that in the access permissions page.

redram’s picture

Node-level comments is a requirement, so we are going to have to revert back to core comments. Too bad. I like this disqus module.

RobLoach’s picture

...... or you could help out with a patch :-) .

kevinquillen’s picture

Couldn't the response from the DISQUS call be parsed and created into comments attributed to that node on demand/during cron? Then add 'via (servicename)' at the bottom? Seems like the first approach. Just spitballing. Then you could still have the DISQUS interface to enter comments, but the core comment module displays them on the node.

RobLoach’s picture

That might be more complicated then it really needs to be. All we really want here is the ability to have node-level Disqus settings. Synchronizing on cron, and then altering Drupal core's comment module could get a bit hairy.

kevinquillen’s picture

Oh, it sounded like #7 wanted the Disqus comments as real comments on the node. My bad.

RobLoach’s picture

Kevin: Did you manage to find out how to disable Disqus on the user profiles?

houstonaplus’s picture

Don't know if this has been addressed already but you can toggle disqus on a node by node basis (provided that the content type is enabled) by using $node->disqus_comments (available in the development version). For example, if you have a custom template, and your user has enabled or disabled comments for that node, you can write a simple code like the following:

if ($node->comment)  //if the user has enabled comments for the node
{
   print $node->disqus_comments;  //then print out the disqus widget
}
dstol’s picture

Status:Active» Needs review
StatusFileSize
new10.61 KB

Here's a patch for this functionality applied against dev 6.x-1.x-dev

RobLoach’s picture

Version:6.x-1.x-dev» 7.x-1.x-dev
Priority:Normal» Critical
Status:Needs review» Patch (to be ported)

Thanks! This is awesome. I made some small tweaks...

  • Checks the status for the block
  • Update hook reports the installation
  • Updating checks the nid so that there arn't duplicates
  • Uses drupal_write_record for the insert (why not)
  • Uses the Comment Settings fieldset to make it look more like the Drupal UI

http://drupal.org/cvs?commit=446054

dstol’s picture

Thanks Rob, I'll also look into the D7 version too.

dstol’s picture

Status:Patch (to be ported)» Needs review
StatusFileSize
new7.07 KB

As promised.

RobLoach’s picture

StatusFileSize
new5.99 KB

I updated the patch to the latest DRUPAL-7--1. Not sure why the update.php isn't registering the update function.

erdembey’s picture

@Rob Loach is this patch applied to the latest v7 release ?

I've tried to solve this issue via special field for this in content types and block visibility php code but no luck.
It will be great to have a solid solution for this issue.

Thanks.

RobLoach’s picture

Status:Needs review» Fixed

Committed to DRUPAL-7--1 http://drupal.org/cvs?commit=483904

dstol’s picture

Woo! Releases soon?

RobLoach’s picture

Of course! http://drupal.org/node/1030556 ...... The problem with the patch was that drupal_write_record($something,$something, 'nid') in Drupal 7 only updates and does not insert if the record doesn't exist.... Weird, yes. Might be a Drupal core bug. Think we should make an issue?

erdembey’s picture

@Rob Loach Thanks, i will try as soons as possible.
Also if there is a bug, we should create an issue ? ;)

dstol’s picture

@Rob, yeah that sounds strange to me, I wonder if the table was primed with some fake data first if it will run an insert.

Also, no love for 6.x?

RobLoach’s picture

Haha :-) ....... If you test out 6.x-1.x-dev and say it's good, I'd be more then happy to tag a release off that.

dstol’s picture

I've been running it without issue on my blog since #15, granted it gets no traffic but the functionality works as expected.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

patrickfgoddard’s picture

I'm having an issue where the enable Disqus comments is viewable/editable for all roles that have permissions to create a node, but I only want certain (admin) roles to control this. Desired workflow would be: all nodes (of a specified content type), would have disqus comments on by default, but only roles with permission could toggle per-node comments on/off. Currently, this feature is on for anyone with access to create a node. Unless I'm missing something?

Netrics’s picture

Status:Closed (fixed)» Needs review

@thund3rbox

This is happening to me too but in 6.x. I am currently going through the code to see if I can find a fix.

EDIT: I made a change in the hook_form_alter() function to include a new permission to handle the display for roles without the permission enabled. Personally I believe if we include the ability to change it for each node type the amount of permissions settings will be to many. The functionality for this feature should be reviewed. I believe we should have an option when editing a content type to include disqus comments or not, that or at least allow the user that has access to add that content type to enable disqus comments or not.

/**
* Implementation of hook_perm().
*/
function disqus_perm() {
  return array(
    'administer disqus',
    'view disqus comments',
    'display disqus comments on profile',
    'enable disqus comments',
  );
}

/**
* Implementation of hook_form_alter().
*/
function disqus_form_alter(&$form, $form_state, $form_id) {
  $types = variable_get('disqus_nodetypes', array());
  if (isset($form['type']) && isset($form['#node']) && !empty($types[$form['type']['#value']]) && $form['type']['#value'] .'_node_form' == $form_id) {
    // Add the Disqus settings into the Comment settings fieldset if it exists.
    if (!isset($form['comment_settings'])) {
      $form['comment_settings'] = array(
        '#type' => 'fieldset',
        '#access' => user_access('enable disqus comments'),
        '#title' => t('Comment settings'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#weight' => 30,
      );
      $node = $form['#node'];
      $form['comment_settings']['disqus'] = array(
        '#tree' => TRUE,
        'status' => array(
          '#type' => 'checkbox',
          '#title' => t('Enable Disqus comments'),
          '#default_value' => isset($node->disqus['status']) ? $node->disqus['status'] : TRUE,
        ),
      );
    }
  }
}

RobLoach’s picture

StatusFileSize
new1.78 KB
rickmanelius’s picture

Hi Rob. I'm assuming the patch in #30 is for 6.x even though the version is set for 7.x?

RobLoach’s picture

Nope, that's for 7.x :-) . Gotta fix in 7 before we get it into 6. Needs a review.

rickmanelius’s picture

Status:Needs review» Reviewed & tested by the community

Patch #30 worked for me on D7 with the latest, dev version of disqus. I can confirm that I'm seeing the proper behavior for all roles as well.

Feel free to set back to 'needs review' if you need additional reviewers.

RobLoach’s picture

Status:Reviewed & tested by the community» Fixed

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit dc4346c on 7.x-1.x, 8.x-1.x by RobLoach:
    #273853 by dstol and Rob Loach: Toggle Disqus Comments per node.
    
    
  • Commit 566d72d on 7.x-1.x, 8.x-1.x by RobLoach:
    Issue #273853 by dstol, Rob Loach: Toggle Disqus Comments permission.
    
    
Rob230’s picture

Issue summary:View changes

Is it possible to control Disqus via code? From reading this thread it looks like you added manual control for a user to disable the comments for a particular node using the interface. That's fine for a blog or something, but I need automatic control that will be interpreted every time the page is made according to the node's fields etc.

I don't need direct support in the Disqus module, I just need to know if this is possible in a custom module/theme, e.g. in a preprocess function. Is there something in the $variables that I can change to instruct Disqus how to behave? If someone could give me some pointers that would be great. In some situations there will be no comments, in some situations comments will be allowed, and in others the comments will be visible, but not open to new comments. This functionality is vital to me and I'm hoping I'll be able to use Disqus.

As a backup, I suppose I could automatically set the "allow Disqus comments" setting of a node when conditions have been met in a hook_node_presave().

slashrsm’s picture

Sure. Disqus comments are added to page in form of an element. Depending how you display it (content area or block) you probably want to use hook_block_view_alter(), hook_page_alter() or something in that direction.

Rob230’s picture

I had a look at the Disqus module. It looks like I can use hook_node_load() and unset $node->disqus. That's easy enough. But I don't know how I can show Disqus comments without allowing new comments. I can't see anything in the Disqus module which does that, and I can't find any options for it on the Disqus website. All I can find is the setting to close comments automatically after a certain number of days. Perhaps it isn't configurable more than that. I will ask Disqus support.

Edit: After looking at disqus_node_delete() it looks like I might be able to use the API to call this: https://disqus.com/api/docs/threads/close/

slashrsm’s picture

You should be able to close threads via Disqus admin interface. You can't do this via Drupal module.

Rob230’s picture

You can't do this via Drupal module.

Hmm. I emailed Disqus support and they also said it wasn't possible. However, I have done it easily. I just used the API and called $disqus->threads->close(). I based it on the code that's already in the Disqus module for deleting threads, since the remove() and close() calls take the same arguments.