We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Comment Leaders Plugin - Any Way to Reset the Totals?

Development and Programming

Deron Sizemore's avatar
Deron Sizemore
1,033 posts
about 18 years ago
Deron Sizemore's avatar Deron Sizemore

I would like to reset the totals each month if possible?

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 18 years ago
Lisa Wess's avatar Lisa Wess

As far as I know, that just looks at the total comments made by each author - so you’d have to wipe out all of the comments to reset it. You could probably modify the plugin to look at only the last 30 days or last calendar month, but if you wanted random reset ability then you’d need a module/extension combination to store that information in the database in its own table.

       
Deron Sizemore's avatar
Deron Sizemore
1,033 posts
about 18 years ago
Deron Sizemore's avatar Deron Sizemore

Yeah, modifying the plugin to only look at the last calendar month or 30 days is kinda what I had in mind. I just don’t know PHP so doing this myself is out of the question. Was kinda hoping someone else had already needed this functionality and made these changes and could throw me a bone. 😊

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
about 18 years ago
Ingmar Greil's avatar Ingmar Greil

I say go with a custom query (or hack the plugin accordingly):

{exp:query sql="SELECT COUNT(entry_id) AS count, name, email, url, author_id, weblog_id, comment_date 
FROM `exp_comments` WHERE FROM_UNIXTIME(comment_date,'%m') = DATE_FORMAT(CURRENT_DATE(), '%m') 
AND FROM_UNIXTIME(comment_date,'%y') = DATE_FORMAT(CURRENT_DATE(), '%y') 
AND status='o' GROUP BY email ORDER BY count DESC LIMIT 10"}
{count} comments by {name}

{/exp:query}

This query shows only comments of the current month of the current year, and hopefully does what you want. If you want the last 30 days instead, that is a slightly different approach.

       
Deron Sizemore's avatar
Deron Sizemore
1,033 posts
about 18 years ago
Deron Sizemore's avatar Deron Sizemore

Wow Ingmar, that’s great! Thanks a lot for supplying me with that code.

Since I make comments in reply to other comments, is there any way to exclude my own comments from the list?

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 18 years ago
Lisa Wess's avatar Lisa Wess

So, how long should I wait before I ask you to add this to the wiki, eh? 😉

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
about 18 years ago
Ingmar Greil's avatar Ingmar Greil
Wow Ingmar, that’s great! Thanks a lot for supplying me with that code. Since I make comments in reply to other comments, is there any way to exclude my own comments from the list?

Certainly. You’d simply add

... AND author_id <> '1'

where 1 is the user_id you want to exclude. So, to sum it up:

{exp:query sql="SELECT COUNT(entry_id) AS count, name, email, url, author_id, weblog_id, comment_date
FROM `exp_comments` WHERE FROM_UNIXTIME(comment_date,'%m') = DATE_FORMAT(CURRENT_DATE(), '%m')
AND FROM_UNIXTIME(comment_date,'%y') = DATE_FORMAT(CURRENT_DATE(), '%y')
AND status='o' AND author_id <> '1'GROUP BY email ORDER BY count DESC LIMIT 10"}
{count} comments by {name}

{/exp:query}

Should do what you want, I hope.

@Lisa: Yes, the wiki. Yes, I will.

       
Deron Sizemore's avatar
Deron Sizemore
1,033 posts
about 18 years ago
Deron Sizemore's avatar Deron Sizemore

Thanks Ingmar. I used “1” for the user_id and it seems to be working (Looking through the admin section I never really found anything that said “user_id” so I assumed since I’m the only user of the site that I would be “1”)

Is that correct?

Thanks again.

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 18 years ago
Lisa Wess's avatar Lisa Wess

Yes, Deron, you’d be 1. You can also check by hovering over your username and looking at the URL, you should see something like id=1 =)

       
Deron Sizemore's avatar
Deron Sizemore
1,033 posts
about 18 years ago
Deron Sizemore's avatar Deron Sizemore

Ahh, every esneaky. 😊

This is great!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.