Is there a way to show the comment count in my template? I searched through the module code and don't see anything that references the comment count so I don't believe it's a current feature. Just wondering.

Thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

interestingaftermath’s picture

I have 1/2 way answered my question.

<a href="<?php print $node_url; ?>#disqus_thread">View Comments</a>

That will display the comments and reactions. Now any suggestions on how to hide that unless there are comments or reactions?

RobLoach’s picture

Status: Active » Fixed

Yay! You can probably change how 0 comments show up in the Disqus administration section. Out of scope for this module, unfortunately. Would have to be on the Disqus end.

Status: Fixed » Closed (fixed)

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

basvredeling’s picture

You can use: print theme('disqus_comments_num', $node->disqus['domain'], $node->disqus['url']); in Drupal 6

ryan.gibson’s picture

Status: Closed (fixed) » Active

How about a 7.x solution?

ryan.gibson’s picture

Version: 5.x-1.3 » 7.x-1.9
Grayside’s picture

These seems like it should be a checkbox on the node settings, or possibly something integrated with managing field display.

Grayside’s picture

Version: 7.x-1.9 » 7.x-1.x-dev
Category: support » feature
Status: Active » Needs work
FileSize
3.79 KB

There's some minimal work to be done here, as the current codebase does not provide the necessary API functionality to easily hack this. I want it more like an on-demand Views' field, which seems to take some more work. Attached patch does a basic refactor of existing code to at least isolate the behavior outside of Views.

Grayside’s picture

Reroll

slashrsm’s picture

+++ b/disqus.module
@@ -808,6 +808,59 @@ function disqus_variable_group_info() {
+ * Display the comments for a given node.
+ *
+ * @param int $nid
+ *   ID of the requested node.
+ * @param bool $render
+ *   Set to FALSE to retrieve the render array.
+ *
+ * @return array|string
+ */
+function disqus_view_comment_count($nid, $render = TRUE) {
+  // Ensure Disqus comments are available on the node user has access to edit this node.
+  $node = node_load($nid);
+  if (user_access('view disqus comments') && isset($node->disqus)) {

Could we use the same function also in hoo_node_view where we add comment count to teasers?

Grayside’s picture

I took a quick look at this, and I think you can. I haven't tested this patch at all, but I think it just might work.

Note that the existing behavior in hook_node_view() adds the disqus information as "links" to the existing links structure. This patch replaces it as a singular link added to that structure.

slashrsm’s picture

It looks that this brakes teaser link. It simply disappears.

imanoop’s picture

Issue summary: View changes

You can get the comment_count from node_load($nid);

<?php
$comment_count = $node->comment_count;
?>

DamienMcKenna’s picture

This could use some minor refactoring to include the new Panels content_type plugin.