Hi all!
I cannot for the life of me figure out how to integrate disqus comments into views. I have "blog" area of my site that I have made with views and I would like the disqus comments to to show on the compilation page. It works fine on the node when you click on the title, but I want it on the overview page, too. I have turned off comments for my blog-type content as per instructions, and disabled commenting site-wide to force comments with disqus, but there is no link, no hint that you can comment on the posts on the overview blog page.

Thanks for your help!

Comments

lintlin’s picture

Well, I did something and now it is displaying. Wish I could tell you what I did...

Still would be great to really know how to do this with views without "getting lucky" :)

Thanks again,
lintlin

narayanis’s picture

I'm having the same issue; Disqus comments are set to appear in the node content, and my View uses the node view, unformatted, with full build mode instead of teaser. any advice?

narayanis’s picture

Using some code from a completely different issue, I created a custom views-row template for my view and did this:

<?php 

print $node;

if(user_access('view disqus comments') && variable_get('disqus_location', 'content_area') == 'content_area'){
	$node = node_load($view->result[0]->nid);
	print theme('disqus_comments', $node->disqus);
}

?>

SolasArd’s picture

Version: 6.x-1.6 » 7.x-1.1

I've run into more a less similiar problem on Drupal 7. On the frontpage view I've set node display to full, and the nodes display fine, and I even get the Disqus comments, but only for the first node. How do I get it to show under all nodes?

JimCraner’s picture

Version: 7.x-1.1 » 6.x-1.7

Hey Narayanis, thanks for the snippet - it worked great!

For anyone else who, like me, is just getting into views template overriding, hopefully this helps:

If you get a "Object of class stdClass could not be converted to string" error centering on the "print $node;" line, check your override file's name. I was trying to use "node-view-VIEWNAME-DISPLAYNAME.tpl.php" as the template suggestion which doesn't work because $node is an object and not a string.

Instead, I placed the same snippet within "views-view-row-node--VIEWNAME--DISPLAYNAME.tpl.php" and it worked fine. If anyone is feeling "mentorful" and wants to explain why it worked in the second template suggestion file and not the first, I'd be appreciative :-)

andrewmugoya’s picture

If you would like to display the Disqus comments on a page and would prefer to use a custom block, below is code you could use::


$node_id = 0;

//CODE BELOW IS TO GET NODE ID FROM URL. ADJUST ACCORDINGLY
$page_url = $_GET['q'];
$split_page_url = explode('/', $curr_url);
$node_id = $split_page_url[2];
// END OF CODE TO GRAB NODE ID

// LOAD DISQUS COMMENTS BELOW
$node = node_load($node_id );
print theme('disqus_comments', $node->disqus);

akosipax’s picture

this is in response to #5, Like you said, the $node variable in the first template is an object because the first template is a node template. node templates have a $node variable too and it contains data about the current node or node being displayed.

on the other hand, the second template's a view template. the $node variable in this view template suggestion is just a string (the HTML output of the node template).