I've got Disqus configured to add comments to my photo albums but haven't figured out how to get comments enabled and displayed for individual photos in an album. Is there a way to do that?

Thanks.

Comments

Anonymous’s picture

Crumb. Forgot to add context. I'm using the Media Gallery module (http://drupal.org/project/media_gallery) to manage multiple photo galleries. I'd like to be able to have Disqus comments for each separate photo.

robloach’s picture

Title: Disqus for Individual Photos? » Entity support
Version: 7.x-1.8 » 7.x-1.x-dev
Category: support » feature

Media Gallery uses bundles and the Entities API, right? Would be great for Disqus to support Entities, then we'd get this out of the box.

robloach’s picture

... And then maybe use UUID to generate a unique string for what the user is looking at?.... Hmm, not sure. Entities seems like the right direction.

robloach’s picture

Maybe switch over to a Field?

pounard’s picture

Sub. Field would be a killer feature, and would allow you to avoid doing SQL queries at load time.

thehong’s picture

Assigned: Unassigned » thehong

Anyone working on this? I am going to make a try this weekend. Please reassign if you already started.

robloach’s picture

Would be very cool to have! Think you'd handle it via a Field for Entities?

thehong’s picture

Component: User interface » Code
Status: Active » Needs work
StatusFileSize
new5.11 KB

This patch just provide basic field, many things are missing:

1. Hardcoding $disqus['title']
2. Does not support entity links (comment counter)
3. Views does not work yet
4. Upgrade path...

bryancasler’s picture

Would love this for taxonomy pages

rerooting’s picture

+1 for the same reasons (taxonomy, uid, other contextual filters, etc.)

Full entity implementation would be rad. Entities do not need to be stored in the database, so one could provide some very interesting capability this way using block/panels cache to temporarily store data fetched from the disqus API.

The field implementation is a good quick start, but we will need to be providing more than that.

We need a simple entity called disqus_comments with these fields exposed to views:

* Author UID (if drupal user)
* Author name
* Author gravatar
* Node/Entity Relationship (for building relations)
* Comment body
* isParent (filter)
* isFlagged (filter)
* Votes
* Likes
* etc...

pol’s picture

+++ b/disqus.moduleundefined
@@ -239,6 +244,7 @@ function disqus_node_view($node, $view_mode) {
 	          );
+            dsm($node->disqus);
       			break;
       	}
         break;

You should remove dsm().

marcingy’s picture

This also needs a migrate path.

semei’s picture

This would be a great feature and it would allow us to use Disqus comments on (non-node) user pages. Any news on this?

thehong’s picture

Assigned: thehong » Unassigned
Status: Needs work » Needs review
StatusFileSize
new4.85 KB
thehong’s picture

StatusFileSize
new4.84 KB

Remove the space.

aaronbauman’s picture

Status: Needs review » Needs work

Doesn't work.
After adding the disqus field, updating disqus settings, and re-saving, no disqus widget appears.
In fact, disqus_field_formatter_view() is never even invoked on the pageview.

Edit: have to re-save existing entities in order for comment form to appear.
is this what you mean by upgrade path?
probably pretty important to include this in any RTBC patch.

slashrsm’s picture

It could be, that your problems originated in field cache.

@marcingy probably meant about per-node configuration, which is currently in a custom table and will be moved to a field with this patch. Sure... we need that if we want to mark this as RTBC.

semei’s picture

I have patched disqus, but when I upload a file and redirect to its page (where I want the comments to appear) I get the following error message:

Notice: Undefined index: comment_settings in disqus_field_update() (line 59 of [...]/sites/all/modules/disqus/disqus.field.inc).

A backtrack tells me that the following functions were involved:
24: disqus_field_update(), 23: _field_invoke(), 22: field_attach_update(), 21: file_entity_file_update(), 20: call_user_func_array(), 19: module_invoke_all(), 18: file_save(), ...

aaronbauman’s picture

StatusFileSize
new5.11 KB

Finally got it working.
Had to change 'url' js setting to absolute.

Updated patch attached.

Leaving on "needs work" because we still need a migration path.

aaronbauman’s picture

oops, forgot to remove dpm()

aaronbauman’s picture

StatusFileSize
new5.03 KB

Current patches don't allow turning disqus comments off.

Updated patch attached.

slashrsm’s picture

I am very excited about this patch. Great job!! It makes so much more sense to implement it this way. We need to support "old way" when we commit this, but we should definitely encourage people to use fields. That's why I think this patch also needs to add some documentation in README.txt. I think we should remove old way and only keep this approach in Drupal 8. Upgrade will be much easier if people will start using field approach already in D7.

Few bits and pieces:

  1. +++ disqus.field.inc	(revision 1937)
    @@ -0,0 +1,149 @@
    +      $title = '';
    +      if (!empty($entity->title)) {
    +        $title = $entity->title;
    +      }
    +      elseif (!empty($entity->name)) {
    +        $title = $entity->name;
    +      }
    +
    

    entity_label()?

    https://api.drupal.org/api/drupal/includes%21common.inc/function/entity_...

  2. +++ disqus.field.inc	(revision 1937)
    @@ -0,0 +1,149 @@
    +          'identifier' => "{$entity_type}/{$entity_id}",
    +          'developer' => variable_get('disqus_developer', FALSE),
    +        );
    

    Identifier is now configurable. We should also support this in field.

  3. +++ disqus.field.inc	(revision 1937)
    @@ -0,0 +1,149 @@
    +      if (!isset($element['comment_settings'])) {
    +        $element['comment_settings'] = array(
    +          '#type' => 'fieldset',
    +          '#access' => user_access('toggle disqus comments'),
    +          '#title' => t('Comment settings'),
    +          '#collapsible' => TRUE,
    +          '#collapsed' => TRUE,
    +          '#group' => 'additional_settings',
    +          '#weight' => 30,
    +        );
    +      }
    +      $element['comment_settings']['disqus_status'] = array(
    

    I get two "Comment settings" vertical tabs. See attached screenshot.

    There is some JS in latest -dev, which creates some summary. We should also use that with fields.

  4. +++ disqus.field.inc	(revision 1937)
    @@ -0,0 +1,149 @@
    +      break;
    +  }
    +  ¶
    +  return $element;
    +}
    

    Some unwanted whitespace.

Grayside’s picture

It makes sense to consider starting a 2.x branch to support Disqus-comments-as-fields rather than trying to support both in one codebranch. This way you can also separate the upgrade path into stages, 7.x-1.x => 7.x-2.x => 8.x-2.x.

nsciacca’s picture

I applied the patch from #21 and it's working fine with my terms after the terms are saved. What needs to be implemented to get it to work on all the other pre-existing terms?

  • Commit 14ed9bf on 8.x-1.x by JayeshSolanki:
    Rerolled the latest patch on #1157912 for entity support of disqus...
  • Commit 99f08cf on 8.x-1.x by JayeshSolanki:
    Merge pull request #2 from angrycodr/generalize_to_entities
    
    Rerolled...