forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Comments => Topic started by: nickfzx on March 17, 2007, 09:48:12 pm

Title: Display Number of Comments a user has made
Post by: nickfzx on March 17, 2007, 09:48:12 pm
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?
Title: Re: Number of Comments
Post by: Joachim Müller on March 18, 2007, 02:47:58 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.
Title: Re: Number of Comments
Post by: nickfzx on March 20, 2007, 05:31:10 am
The raw query is this:
Code: [Select]
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.
Title: Re: Number of Comments
Post by: nickfzx on March 20, 2007, 06:16:26 am
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:
Code: [Select]
// Displays comments for a specific picture
...
and
Code: [Select]
// HTML template for the display of comments
...

so now in theme.php find:
Code: [Select]
<b>{MSG_AUTHOR}</b>replace with:
Code: [Select]
<b>{MSG_AUTHOR} {NUMBER_COMMENTS}</b>find:
Code: [Select]
($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:
Code: [Select]
$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:
Code: [Select]
            '{AUTHOR_ID}' => $row['author_id']replace with:
Code: [Select]
            '{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.
Title: Re: Number of Comments
Post by: nickfzx on March 27, 2007, 10:50:11 pm
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.
Title: Re: Display Number of Comments a user has made
Post by: Joachim Müller on March 28, 2007, 07:57:57 am
It's recommended to use the coppermine query functions.
Title: Re: Display Number of Comments a user has made
Post by: nickfzx on March 28, 2007, 12:03:32 pm
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?
Title: Re: Display Number of Comments a user has made
Post by: Joachim Müller on March 29, 2007, 08:14:32 am
Makes your mod more robust in case that the queries should change in future versions (e.g. maintenance releases).
Title: Re: Number of Comments
Post by: andi_k on June 28, 2007, 02:19:03 pm

find:
Code: [Select]
($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:
Code: [Select]
$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.
Title: Re: Display Number of Comments a user has made
Post by: DaBe on January 01, 2008, 11:09:55 pm
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
Title: Re: Display Number of Comments a user has made
Post by: Dogbot on August 13, 2008, 11:29:12 am
How would or could you edit this so that only the comments made by members on other members photos where counted?

.D.