Display Number of Comments a user has made Display Number of Comments a user has made
 

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

Main Menu

Display Number of Comments a user has made

Started by nickfzx, March 17, 2007, 09:48:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nickfzx

Ok, this one shouldn't be too hard.

Basically you know on this forum it say how many posts I have made.  Well would be cool if it said how many comments a user has made in coppermine gallery next to each comment they make.

I don't think this should be too hard to make.  Was looking at the database and it looks like all I would have to do is go into the comments table...give the user ID I want the comment count for...if there is no entry then it is 0 comments for that user, if it there is an entry then the number of rows associated with that UserID is the comment count.

Any flaws in my evil plan?  Or should I just jump in and start coding it?

Joachim Müller

Quote from: nickfzx on March 17, 2007, 09:48:12 PM
Or should I just jump in and start coding it?
Start coding it ;D. Without having taken a look into the code, my guess is though that you'll have to add some queries, which might have a performance impact.

nickfzx

#2
The raw query is this:
SELECT COUNT( * ) AS `Rows`
FROM `cpg_comments`
WHERE author_id = XX

XX being the the author_id variable in the theme file.

not sure how efficient it is or how much extra strain it will put on your server.

in the next post I will outline how to integrate it with your theme file.

nickfzx

so if anyone wants to display the total number of comments that a user has made in coppermine next to each comment this is what to do:

you will need to copy these two sections from theme.inc.php to theme.php if you have not already:
// Displays comments for a specific picture
...

and
// HTML template for the display of comments
...


so now in theme.php find:
<b>{MSG_AUTHOR}</b>
replace with:
<b>{MSG_AUTHOR} {NUMBER_COMMENTS}</b>
find:
($row['author_id'] == 0 ) ? $profile_lnk = stripslashes($row['msg_author']): $profile_lnk = "<a href=\"profile.php?uid={$row['author_id']}\">".stripslashes($row['msg_author'])."</a>";
after add:
$authorid = $row['author_id'];
$number_of_comments = sprintf("SELECT COUNT( * ) AS `Rows` FROM cpg_comments WHERE author_id=$authorid");
$resultx = mysql_query($number_of_comments);
$bow = mysql_fetch_assoc($resultx);

find:
            '{AUTHOR_ID}' => $row['author_id']
replace with:
            '{AUTHOR_ID}' => $row['author_id'],
    '{NUMBER_COMMENTS}' => $bow['Rows']


and thats it...it will just display the number next to the username of the commenter with no explanation of what it means so you may want to format it a little nicer or give an explanation.

I've tested it and it works with no visible side effects, let me know if you have any troubles.

nickfzx

a valid mod no?  ;D

see it in action here:
http://www.amateurillustrator.com/galleries/displayimage.php?album=topn&cat=0&pos=0

notice the comment counter next to each username.

Joachim Müller

It's recommended to use the coppermine query functions.

nickfzx

ah ok, I will look into changing it.

What are the reasons for using the copper mine query functions...is it just for clarity or does it affect the way it works?

Joachim Müller

Makes your mod more robust in case that the queries should change in future versions (e.g. maintenance releases).

andi_k

Quote from: nickfzx on March 20, 2007, 06:16:26 AM

find:
($row['author_id'] == 0 ) ? $profile_lnk = stripslashes($row['msg_author']): $profile_lnk = "<a href=\"profile.php?uid={$row['author_id']}\">".stripslashes($row['msg_author'])."</a>";
after add:
$authorid = $row['author_id'];
$number_of_comments = sprintf("SELECT COUNT( * ) AS `Rows` FROM cpg_comments WHERE author_id=$authorid");
$resultx = mysql_query($number_of_comments);
$bow = mysql_fetch_assoc($resultx);


I cannot find this.

DaBe

hello

How I can use this mod in the userlist also usermgr.php ?

and is the mod compatible with 1.4.14 coppermine version with modpack?


thx

Dogbot

How would or could you edit this so that only the comments made by members on other members photos where counted?

.D.