Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1] 2 3   Go Down

Author Topic: comments in gallery  (Read 19860 times)

0 Members and 1 Guest are viewing this topic.

heavensportal

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 259
    • The Fantasy Attic
comments in gallery
« on: January 25, 2014, 03:20:42 am »

I was wondering if there is some plugin or code to add that can show the comments count of each member without needing to go to users and going through all the pages. Something like SMF has for posters.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: comments in gallery
« Reply #1 on: January 25, 2014, 01:15:08 pm »

Where do you want to display that information? Next to the user name for each comment? On a separate statistics page? Or maybe somewhere else?
Logged

heavensportal

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 259
    • The Fantasy Attic
Re: Re: comments in gallery
« Reply #2 on: January 25, 2014, 11:24:22 pm »

Where do you want to display that information? Next to the user name for each comment? On a separate statistics page? Or maybe somewhere else?

A separate page would be ok or even some code to apply to my forum so other members will be inspired to comment on the remarkable artwork.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: comments in gallery
« Reply #3 on: January 27, 2014, 03:42:14 pm »

So you want a simple table like
Code: [Select]
user name | comments
--------------------
foo       | 47
bar       | 11
without pagination, right? Do you want to hide users without comments, i.e. is there a minimum number of comments a user needs to appear in the list?
Logged

heavensportal

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 259
    • The Fantasy Attic
Re: comments in gallery
« Reply #4 on: January 27, 2014, 03:56:30 pm »

yes simple like that  so I can put it in a block in my smf forum or in the gallery itself, the easiest one for you to do.

user name total comments made are the only thing needed and only the ones that comment should be in there.

I am trying to get them to comment more so the minimum amount would be say 10 comments, then they will see how many as they accumulate them...

This way the members can see the listing too for incentive.

I hope that makes sense.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: comments in gallery
« Reply #5 on: January 28, 2014, 09:13:30 am »

Copy this to a new PHP file in your gallery root:
Code: [Select]
<?php

$min_comments 
10;

define('IN_COPPERMINE'true);
require(
'include/init.inc.php');
$result cpg_db_query("SELECT ".$cpg_udb->field['username']." AS user_name, COUNT(*) as num_comments FROM ".$cpg_udb->usertable." AS u INNER JOIN {$CONFIG['TABLE_COMMENTS']} AS c ON c.author_id = u.".$cpg_udb->field['user_id']." GROUP BY user_name HAVING num_comments >= $min_comments ORDER BY num_comments DESC");
pageheader();
starttable();
echo 
"<tr><td><strong>User name</strong></td><td><strong>Comments</strong></td></tr>";
while (
$row mysql_fetch_assoc($result)) {
    echo 
"<tr><td>{$row['user_name']}</td><td>{$row['num_comments']}</td></tr>";
}
endtable();
pagefooter();
« Last Edit: January 28, 2014, 11:23:49 am by Αndré »
Logged

heavensportal

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 259
    • The Fantasy Attic
Re: comments in gallery
« Reply #6 on: January 28, 2014, 10:07:41 am »

copy/pasted into new php called comments.php and uploaded but where am I supposed to go to see the listing?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: comments in gallery
« Reply #7 on: January 28, 2014, 10:37:56 am »

Logged

heavensportal

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 259
    • The Fantasy Attic
Re: comments in gallery
« Reply #8 on: January 28, 2014, 10:44:21 am »

Maybe I did something wrong, somehow because when I type the url into the browser for the file I get

Critical error
There was an error while processing a database query

I even changed the name to top-comments.php with same results
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: comments in gallery
« Reply #9 on: January 28, 2014, 10:46:03 am »

Please enable debug mode to get the extended error message. The file name doesn't matter.
Logged

heavensportal

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 259
    • The Fantasy Attic
Re: comments in gallery
« Reply #10 on: January 28, 2014, 10:50:45 am »

I also added a ?> at the end of the file too, was that wrong?

Here is what I get for the debug

Critical error

There was an error while processing a database query.

While executing query 'SELECT user_name, COUNT(*) as num_comments FROM `thefanta_attic`.smf8_members AS u INNER JOIN cpg14x_comments AS c ON c.author_id = u.user_id GROUP BY user_name HAVING num_comments >= 10 ORDER BY num_comments DESC' in top-comments.php on line 7 mySQL error: Unknown column 'user_name' in 'field list'


File: /home/thefanta/public_html/attic/cpg/include/functions.inc.php - Line: 272
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: comments in gallery
« Reply #11 on: January 28, 2014, 10:55:02 am »

I just updated the above code, so it also works with bridged galleries.
Logged

heavensportal

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 259
    • The Fantasy Attic
Re: comments in gallery
« Reply #12 on: January 28, 2014, 10:59:52 am »

My gallery hates me:

Critical error

There was an error while processing a database query.

While executing query 'SELECT user_name, COUNT(*) as num_comments FROM `thefanta_attic`.smf8_members AS u INNER JOIN cpg14x_comments AS c ON c.author_id = u.real_name GROUP BY user_name HAVING num_comments >= 10 ORDER BY num_comments DESC' in top-comments.php on line 7 mySQL error: Unknown column 'user_name' in 'field list'


File: /home/thefanta/public_html/attic/cpg/include/functions.inc.php - Line: 272
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: comments in gallery
« Reply #13 on: January 28, 2014, 11:09:14 am »

Sorry, my mistake. Updated code again.
Logged

heavensportal

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 259
    • The Fantasy Attic
Re: comments in gallery
« Reply #14 on: January 28, 2014, 11:15:38 am »

yes! it appears now however, it is pulling comments from the forum post counts and not the actual gallery comments done.

So sorry to put you through all this
Logged

heavensportal

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 259
    • The Fantasy Attic
Re: comments in gallery
« Reply #15 on: January 28, 2014, 11:18:05 am »

oops forgot to add that the totals are waaaaaaay off.

one is listed at 3000+ when she only has 95 forum posts and 5 gallery comments
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: comments in gallery
« Reply #16 on: January 28, 2014, 11:24:16 am »

Please try the updated code again. Seems that I'm a little bit tired today ;)
Logged

heavensportal

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 259
    • The Fantasy Attic
Re: comments in gallery
« Reply #17 on: January 28, 2014, 11:26:53 am »

Eureka it is showing now, thank you so very much and sorry to put you through the problem dealing with my silly site....it never behaves normal even with out of the box, unedited software.

Thank you very much. :-*
Logged

heavensportal

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 259
    • The Fantasy Attic
Re: comments in gallery
« Reply #18 on: February 07, 2014, 10:03:27 am »

It's me again...is there any way to NOT show the admins comments in that coding you were so kind to create for this.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: comments in gallery
« Reply #19 on: February 10, 2014, 11:36:06 am »

Try
Code: [Select]
<?php

$min_comments 
1;

define('IN_COPPERMINE'true);
require(
'include/init.inc.php');
$result cpg_db_query("SELECT ".$cpg_udb->field['username']." AS user_name, COUNT(*) as num_comments FROM ".$cpg_udb->usertable." AS u INNER JOIN {$CONFIG['TABLE_COMMENTS']} AS c ON c.author_id = u.".$cpg_udb->field['user_id']." WHERE ".$cpg_udb->field['usertbl_group_id']." NOT IN (".implode(', '$cpg_udb->admingroups).") GROUP BY user_name HAVING num_comments >= $min_comments ORDER BY num_comments DESC");
pageheader();
starttable();
echo 
"<tr><td><strong>User name</strong></td><td><strong>Comments</strong></td></tr>";
while (
$row mysql_fetch_assoc($result)) {
    echo 
"<tr><td>{$row['user_name']}</td><td>{$row['num_comments']}</td></tr>";
}
endtable();
pagefooter();
Logged
Pages: [1] 2 3   Go Up
 

Page created in 0.022 seconds with 20 queries.