Page 1 of 1

[solved] removing comments still leaves a count of them?

Posted: Fri May 19, 2006 3:41 am
by Dr.CSS
i've been testing the comments module and love it!  just one thing, i've also added a counter and it works great also but with all the testing i've made a lot of comments, when i delete them they still show up in the count even if i delete every comment made on that page or just delete every comment ever made they still show up in the count and if i add another it goes up by one, where is it storing this information so i can get some pages w/o a count if the comments have been deleted. client may find the need to delete a comment oh you know like something offensive(?sp) any ideas out there?

  mark

Re: removing comments still leaves a count of them?

Posted: Fri May 19, 2006 5:12 pm
by Elijah Lofgren
If you're using the count_news_comments tag I wrote:
http://forum.cmsmadesimple.org/index.ph ... l#msg24827
then I can't seem to reproduce your problem.

What is the code you are using to count comments?

Re: removing comments still leaves a count of them?

Posted: Fri May 19, 2006 5:15 pm
by Dr.CSS
yep same one..
i can't reset it to 0 deleting the comments just leaves it with no comments but the count still shows how ever many were there b4,
i know it works right bcuz if you add another comment the count goes up 1...

  mark

Re: removing comments still leaves a count of them?

Posted: Fri May 19, 2006 6:55 pm
by Elijah Lofgren
I don't know what's wrong. I've tested it and it works fine for me. Whenever I delete or disable a comment the count goes down.

This is the code I am using:
global $gCms;

$db = &$gCms->db;

// First we get the total number of visits ever
$q = "SELECT * FROM ".cms_db_prefix()."module_comments WHERE  page_id =".$params['thenewsid']." AND module_name='News' AND active='1'";
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
    echo 'DB error: '. $db->ErrorMsg()."";
}
$num_rows = $dbresult->RecordCount();
echo $num_rows;

Re: removing comments still leaves a count of them?

Posted: Sat May 20, 2006 3:40 am
by Dr.CSS
this is what you said to use... so that's what i've been using.V... didn't know that." AND module_name='News' AND active='1'" this might make a diff...

For a regular page something like this should work:
Code:
global $gCms;

$db = &$gCms->db;

// Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_comments WHERE  page_id =".$params['thenewsid'];
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
    echo 'DB error: '. $db->ErrorMsg()."";
}
$num_rows = $dbresult->RecordCount();
echo $num_rows;

  mark

Re: removing comments still leaves a count of them?

Posted: Sat May 20, 2006 4:27 am
by Elijah Lofgren
mark wrote: this is what you said to use... so that's what i've been using.V... didn't know that." AND module_name='News' AND active='1'" this might make a diff...
That's only needed if this is counting comments in the news module. If you're counting comments on a page put the following in a userdefind tag named "count_page_comments":
mark wrote: global $gCms;

$db = &$gCms->db;

// Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_comments WHERE  page_id =".$params['thenewsid'];
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
    echo 'DB error: '. $db->ErrorMsg()."";
}
$num_rows = $dbresult->RecordCount();
echo $num_rows;
Then in your page template put this:

Code: Select all

Number of comments: {count_page_comments thenewsid=$content_id}
That works for me for counting comments on the current page.

Re: removing comments still leaves a count of them?

Posted: Wed May 24, 2006 11:27 pm
by Dr.CSS
Hello Elijah
is there any way to make this cycle thru a list to check which module it's counting for....

ge_id =".$params['thenewsid']." AND{ if module_name='News' AND active='1'}{ else if module_name='Blog' AND active='1'}{ else if module_name='Album' AND active='1'}{/if}";

i'm no programmer but hope you get the idea.....

  mark

Re: removing comments still leaves a count of them?

Posted: Wed May 31, 2006 2:54 am
by Elijah Lofgren
mark wrote: Hello Elijah
is there any way to make this cycle thru a list to check which module it's counting for....

ge_id =".$params['thenewsid']." AND{ if module_name='News' AND active='1'}{ else if module_name='Blog' AND active='1'}{ else if module_name='Album' AND active='1'}{/if}";

i'm no programmer but hope you get the idea.....
I don't really understand what you mean. What exactly are you trying to do?

Re: removing comments still leaves a count of them?

Posted: Wed May 31, 2006 3:18 am
by Dr.CSS
your original code said...

module_comments WHERE  page_id =".$params['thenewsid']." AND module_name='News' AND active='1'";

but i use the generic code...

module_comments WHERE  page_id =".$params['thenewsid']; $dbresult = $db->Execute( $q );

if i use the, upper first code, count in comments and use comments in more than the News module like the first code it won't count the comments for any other module, BLog, Album pictures,  so i was hoping there was some way for it to check which module it is counting for...

i've deleted some test comments and it still shows the count of them ie. i've had 7 comments on one Blog and now that i deleted some it still says 7 if you clik Add a Comment you can see there is only 2 left, it's like ghost comments are being counted...
goto this page  http://www.multiintech.com/index.php?page=blogger  and you see a count of comments second one down says [4] last one says [2] but each one has 1 less than it says because i've deleted some, one from each, there was an article/blog post that had 7 comments at one time to test it and i deleted them all and it still said 7
like i said i use the count tag in the comments module template and comments are used for News and Blog so the generic code was used or if i tried to say News it wouldn't count in the Blog module  ok this starting to ramble.. not sure how to make it any more clear...
was hoping it could be made to check which Module it was counting for, as i am using the tag inside the comment template as in...

{$addcomment}[ {count theid=$entry->id} ]

Re: removing comments still leaves a count of them?

Posted: Wed Jan 30, 2008 7:28 pm
by streever
is there a way to inject this in for Calendar? I get a DB Error....

Re: [solved] removing comments still leaves a count of them?

Posted: Sat Feb 02, 2008 5:39 pm
by Dr.CSS
How are you implementing it?

Re: [solved] removing comments still leaves a count of them?

Posted: Tue Feb 05, 2008 8:30 pm
by streever
good question :)

I tried the "generic" (page) one & the "News" model.

I am not sure what the "calendar" model would be, and tested several, and none worked! :)