Download & Extend

Injecting Disqus as a Variable in Drupal 7 is broken

Project:Disqus
Version:7.x-1.x-dev
Component:User interface
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (works as designed)

Issue Summary

Hi!

Disqus comments and entry box end up above the "link bar" that comes at the end of each node's content. I think it should be below there, like the normal Drupal comment area. This happens on at least the Garland, Stasis and Sky themes.

See screenshot.

Thanks in advance.

AttachmentSize
elehackscreenshot.PNG99 KB

Comments

#1

I think this positioning (as part of the node) leads to another problem: Search picks up the contents of the embedded disqus code.

See screenshot. Note the var disqus_title = "Tes"... in the second search result

AttachmentSize
var disqus_title.PNG 96.08 KB

#2

If you know a way to stick it underneath the links, then I'd love to do it. I was considering possibly sticking the comments into a block, but not sure if that's the best place for them. I'm not sure, any thoughts?

#3

This is by design (not claiming it's good design :). Disqus injects its content into $content (as $node->content['disqus'] which comes, by design, before $links in most (all?) circumstances. The same design decisions makes it impossible, sadly, to have Disqus comments attached to any content type (CCK) that doesn't use this field in its node template.

#4

Trying to rationalize this away by saying it's by design misses the point.

In my estimation it's very bad in that it makes the 'links' area nearly impossible to find. Further it is not behaving the same as Drupal's normal comments, which themselves appear below the links area.

I just checked and .. in the Garland theme .. you can position a block in the "content" region and it appears below the links area. e.g. the Disqus Combo Widget Thingymajob is appearing in the place I would want the Disqus comment box to appear.

Another option is to add it to the links variable. Except doing so would violate some expectation that the links are short and small. Hurmph.

#5

I have an idea... Some DOM manipulation could move the disqus widget below the links when the page is rendered.

The links are a div with an appropriate id= to aid identifying where the links are. At least this is true in Garland I suppose other themes may render the links differently. Anyway when the disqus module includes the script tag for the disqus code it could also include a bit of jquery to move the disqus widget elsewhere.

#6

I too didn't want the Disqus comment injected straight into the body. Instead, I'd rather have control over where they appeared by using my theme. I currently use Drupal 5.x, so these instructions maybe a little different for 6.x, but I've managed to figure out how to do this.

Line 76-79 in disqus.module currently has this:

$node->content['disqus'] = array(
   '#value' => $disqus,
   '#weight' => 10,
);

As jluster said above, this injects the Disqus code into the body with a weight of 10. If you're fine having the node links below the comments, you can modify the weight value to how you'd like it. Otherwise, change the code to this:

$node->disqus_comments = $disqus;

This creates a variable when the node is viewed called $disqus_comments that you can place anywhere in your node.tpl.php

Someone else can chime in and tell you if the code is any different for Drupal 6.x, but this is the Drupal 5.x solution. Thanks!

#7

Version:6.x-1.3» 6.x-1.x-dev

Would love to figure out a solution here.

#8

why not have the comment form appear in a block?
what's wrong with that? (and no, it is not a rhetorical
question, i do want to know why it is not an option)

#9

Status:active» fixed

I've committed a fix to add a "Disqus Comments" block that displays the comments when the "Block" location is set in the Disqus administration. It will be in the next 6.x-1.x-dev update, and the upcoming 6.x-1.5.

#10

Status:fixed» closed (fixed)

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

#11

Status:closed (fixed)» needs review

New 6.x-1.5 version did not fix my problem of having Disqus comments directly injected into content. It is much more preferable to have them attached as property of the node. Attached is a quick patch file that will apply the necessary change to Drupal 6. It is the same approach as my Drupal 5 solution above in #6, but the line that gets inserted is this:

$node->disqus_comments = theme('disqus_comments', $node->disqus);

AttachmentSize
disqus.module.diff 783 bytes

#12

How about this? Provide an option for the variable injection.

AttachmentSize
286057.patch 4.39 KB

#13

Great work, Rob! This way admins can decide how they want the comments displayed.

#14

This is interesting. I was looking to have Disqus and regular comments at the same time, and thus want Disqus to appear underneath the Drupal comments styled by comments.tpl
The only reason I want Disqus is to enable twitter & facebook comments, but as it appears, Disqus must show up in 'content', which places is above the communities comments and devalues them (visually).

#15

If someone tests this patch, and then thinks it's ready to be committed, then sets the status to RTBC. I'd be happy to commit it :-) .

#16

Title:Disqus Comments area positioned incorrectly on page» Own project
Project:Disqus» Project
Version:6.x-1.x-dev» 5.x-1.x-dev
Category:bug report» task
Priority:normal» critical
Status:needs review» needs work

Hi All,

I am using garland theme. In comment section i want first comment form section then liasting of all comments. Currently it shows all listing comments then comes comment form section .
What can i do for that.

Thanks

#17

Title:Own project» Disqus Comments area positioned incorrectly on page
Project:Project» Disqus
Version:5.x-1.x-dev» 6.x-1.x-dev
Category:task» bug report
Priority:critical» normal
Status:needs work» needs review

@pankaj467

Please don't hijack issues like that. Reset to original settings.

#18

Status:needs review» reviewed & tested by the community

I've applied Rob Loach's patch, even to 6.x-1.6, and it works beautifully. I have only tested it with Injected Variable because that's all I needed it for. I believe it is ready to be committed!

#19

I also applied the patch to 6.x-1.6 and it has worked very well. I also only tested "Injected Variable", but it works nicely for my uses. Thanks!

#20

Version:6.x-1.x-dev» 7.x-1.x-dev
Status:reviewed & tested by the community» fixed

http://drupal.org/cvs?commit=415166
http://drupal.org/cvs?commit=415158

#21

Title:Disqus Comments area positioned incorrectly on page» Injecting Disqus as a Variable in Drupal 7 is broken
Status:fixed» active

Injecting Disqus as a variable in Drupal 7 is broken, but not sure if it's even needed. Will leave this open to track. If you're using Drupal 7 and Disqus, mind sharing your thoughts here?

#22

Status:active» fixed

Removed this as it doesn't really need to be there in Drupal 7.

#23

Status:fixed» closed (fixed)

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

#24

Status:closed (fixed)» needs review

Why does this not have to be there in Drupal 7? The comments are still being posted above the submitted data. Is there a way to use hide() for the disqus comments to render them later?

#25

I believe hide() and everything should work. Mind having a try at it? I assumed it wouldn't be needed since the Drupal 7 version uses renderable arrays rather then calling the theme() system directly.

#26

Status:needs review» closed (works as designed)

In Drupal 7, the Disqus element is a renderable array. I'd consider this fixed. If not though, feel free to post up some sample code and we can get it back in.

#27

Took me a while to track down the variable I needed to insert into my template file for the "Injected Variable" option. Might be a good idea to put into the help text:
<?php print $node->disqus_comments = theme('disqus_comments', $node->disqus); ?>

nobody click here