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

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

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

Post 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
Last edited by Anonymous on Sat Feb 02, 2008 5:35 pm, edited 1 time in total.
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am

Re: removing comments still leaves a count of them?

Post 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?
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. :)
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: removing comments still leaves a count of them?

Post 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
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am

Re: removing comments still leaves a count of them?

Post 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;
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. :)
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: removing comments still leaves a count of them?

Post 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
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am

Re: removing comments still leaves a count of them?

Post 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.
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. :)
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: removing comments still leaves a count of them?

Post 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
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am

Re: removing comments still leaves a count of them?

Post 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?
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. :)
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: removing comments still leaves a count of them?

Post 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} ]
streever

Re: removing comments still leaves a count of them?

Post by streever »

is there a way to inject this in for Calendar? I get a DB Error....
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

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

Post by Dr.CSS »

How are you implementing it?
streever

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

Post 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! :)
Post Reply

Return to “CMSMS Core”