Download & Extend

Comment count as a variable in node.tpl.php

Project:Disqus
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:ximo
Status:active

Issue Summary

Comment count is shown in the $links variable in node.tpl.php, which is fine for most I suppose.

But $links isn't very flexible, and it would be really nice to have this as a stand-alone variable in node.tpl.php. A disqus_preprocess_node() should be able to do this.

Note to self: cook up a patch that introduces this.

Comments

#1

Subscribing

#2

Subscribing..

#3

Unfortunately the number of comments isn't store anywhere server-side so all we can do is print the theme function that will use javascript to replace the link "Comments" with "X Comments". (That's how the existing comments link works in the $links variable.)

<?php print theme('disqus_comments_num', $SHORTNAME, 'node/'. $node->nid, t('Comments')); ?>

To do more I think we need to dig into drupal behaviors in disqus.js

#4

Also, I think the it was implemented with JS because it most systems it will ruin caching if the comment counts keep changing in the page HTML. This is not the case if your caching is strictly time based.

#5

subscribling

#6

subscribing

#7

subscribing for D7

#8

Subscribing

#9

Let me provide a bad solution for this :) ;

In drupal 7 i can manage to isolate the comment count in $links with hiding the other variables in $links.
For example;

<?php
      hide
($content['links']);
     
hide($content['links']['statistics']);
     
hide($content['links']['node']);
?>

With this method i can prevent the read count and read more text appearing with comment count.
After that i can use

<?php
     
print render($content['links']);
?>

without a problem.

Btw. i see 0 comments where it should be 0 comment (isn't it?) and also it seems localization is not available in this context.

#10

Is this theming function an incomplete feature? I don't see anything in the function that actually pulls the number of comments from the API. It seems to just render a linked bit of text.