This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Comment count outside the script
#1

I want to display the comment count outside the php code that generates the comments. I wrote an SQL query that works but it does not refresh when the comment is added so the count is always 1 under the actual count. After the comment is added and I manually reload the page, the correct count is displayed.

Any ideas? The code in commentics is:
PHP Code:
<?php 
$number_of_comments
= cmtx_number_of_comments();
, but if I write something like
PHP Code:
<?php echo $number_of_comments;?>
outside the commentics code it does not display anything.
Reply
#2

Hi,

It's going to be very difficult to accurately display the number of comments above the script as it won't know whether the comment that has just been submitted will be added or not.

Have you completed the interview?
Reply
#3

(11-Feb-2012, 01:30 PM)Steven Wrote:  It's going to be very difficult to accurately display the number of comments above the script as it won't know whether the comment that has just been submitted will be added or not.

Hi Steven, is there no work-around for this?

I'm trying to do the same as Quiksilver02x.
Reply
#4

(30-Aug-2012, 08:41 AM)organicAnt Wrote:  
(11-Feb-2012, 01:30 PM)Steven Wrote:  It's going to be very difficult to accurately display the number of comments above the script as it won't know whether the comment that has just been submitted will be added or not.

Hi Steven, is there no work-around for this?

I'm trying to do the same as Quiksilver02x.

Wow...it has been so long since I asked this question I forgot I had done it. I managed to find a temporary workaround; it isn't ideal but it works. What I did is specific to my site's design so it may not work for you:

I essentially have a 'site.php' page containing two main parts: the upper div and the lower div (lower div contained a tabbed menu -with comment count- and the commentics script itself below it).

What I did was completely remove the entire bottom div from the 'site.php' page and put all that code into the commentics script itself, so when that script is called it also displays the code I added to it. Make sense? So when a comment is added and the commentics script refreshes, so does my code since it's physically inside the commentics script.
Reply
#5

Hi Quicksilver, thank you very much for the swift reply.

Although, I don't think your suggestion will work in my case because, on the jquery website I'm building, the comments only get loaded (into an iframe) when the user clicks on the Comments button. I'd like the Comments button text to include the amount of comments that page (like: "Comments (8)") contains before the comments are actually displayed in the iframe.

I think it'd be helpful to know in advance how popular the comments are before clicking on the button to display them. It'd prevent possible disappointment and annoyance of clicking on several Comments buttons and finding their contents empty.

Could master jedi Steven consider this a feature request?
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Steven
29-Sep-2021, 11:41 AM
Last Post by afoster
02-Aug-2020, 10:40 PM
Last Post by Steven
10-Jan-2018, 09:58 PM
Last Post by noblues
08-Mar-2015, 05:08 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)