Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
meramo CreditAttribution: meramo commentedSubscribing
Comment #2
noslokire CreditAttribution: noslokire commentedSubscribing..
Comment #3
jumpfightgo CreditAttribution: jumpfightgo commentedUnfortunately 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
Comment #4
teastburn85 CreditAttribution: teastburn85 commentedAlso, 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.
Comment #5
frobsubscribling
Comment #6
espenmoe CreditAttribution: espenmoe commentedsubscribing
Comment #7
erdembey CreditAttribution: erdembey commentedsubscribing for D7
Comment #8
kenneth@fiil.eu CreditAttribution: kenneth@fiil.eu commentedSubscribing
Comment #9
erdembey CreditAttribution: erdembey commentedLet 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;
With this method i can prevent the read count and read more text appearing with comment count.
After that i can use
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.
Comment #10
datawench CreditAttribution: datawench commentedIs 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.
Comment #11
Poieo CreditAttribution: Poieo commentedI was using the following successfully in Drupal 6. Doesn't anyone know the equivalent for Drupal 7?
Comment #12
ryan.gibson CreditAttribution: ryan.gibson commentedYea, this is what I'm looking to do as well, except I'm looking to add the Disqus comment count as a custom Display Suite field.
Comment #13
Poieo CreditAttribution: Poieo commentedThis is what I ended up using in D7:
The disqus script converts it into 'X comments and Y reactions'.
@ryanissamson - You might try http://drupal.org/project/computed_field with the above code to us it in display suite.
Comment #14
ryan.gibson CreditAttribution: ryan.gibson commentedPoieo, thanks for the info. I'm wondering, why would I need the computer field module? Couldn't I just add a custom php field in DS display using the php filter?
I've actually given that a shot, it doesn't seem to be working just yet.
Comment #15
heshanlkI did this. This may helpful.
Comment #16
dsbrianwebster CreditAttribution: dsbrianwebster commentedI agree this should be available as a field, not in the links variable on the teaser.
Here's a solution I'm using in the meantime using a display suite code field...
Field code snippet:
Comment #17
Grayside CreditAttribution: Grayside commentedI rolled a partial patch as part of https://drupal.org/node/590582#comment-7760907. I thought the issues were explicitly for different versions :/
Comment #18
kclarkson CreditAttribution: kclarkson commented@Delicious Simplicity This is GREAT !!! Thank you so much !
Is there some way to get this added as an additional module to disqus? I am sure many people would like to see this feature.
Comment #19
lionelmes CreditAttribution: lionelmes commentedIt has information I have been searching for a long time. It is my problem. Thanks heshan.lk and all. I am fix it. I use relax on frivjogo.info
Comment #20
Rob_Feature CreditAttribution: Rob_Feature commentedAnyone looking to just print this directly in their node template can do this (or change the span to a div):
Comment #21
lslinnet CreditAttribution: lslinnet as a volunteer commentedDo not hardcode the identifier, use the one in $node->disqus['identifier']; else you will have issues if you need to use another identifier.
Comment #22
7thkey CreditAttribution: 7thkey as a volunteer commentedDoes anyone know how to do it in Drupal 8? I need to show count comments on Teaser display.
Comment #23
renguer0 CreditAttribution: renguer0 as a volunteer commented+1 to D8 request.
I will try that on localhost to do some testing.
Comment #24
ankithashetty+1 to D8 request.