1 (edited by 2008-08-12 19:12:35)

Topic: [HACK] List all commenters

Name: List all commenters
Author: FI-DD
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: on the active news page you can add a list of all people that have commented on that article.
Demo: [url="http://democute.de.funpic.de/cute/example2.php"]here[/url
Instructions:
///////////////////////////////////
Installation:

1. Open functions.inc.php and add this at the end of the file before the last ?>

//////////////////////////////////////////////////////////////////
// Function: Lists all commenters with mail or url when available
function list_commenters($news, $linebreak, $separator) {
global $cutepath;
$alle_comments = file($cutepath."/data/comments.txt");
$i=0;
foreach($alle_comments as $comments_line)
{
$comments_line = trim($comments_line);
$comments_line_arr = explode("|>|", $comments_line);
if($news == $comments_line_arr[0])
{
$individual_comment = explode("||", $comments_line_arr[1]);
foreach ($individual_comment as $single_comment)
{
$single_comment_arr = explode("|", $single_comment);
if (($single_comment_arr[0] != "") && (!stristr($output, $single_comment_arr[1])))
{
$i++;
if($single_comment_arr[2] != "none")
{
if( preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $single_comment_arr[2])){ $url_target = "";$mail_or_url = "mailto:"; }
else
{
$url_target = "target=\"_blank\"";
$mail_or_url = "";
if(substr($single_comment_arr[2],0,3) == "www") $mail_or_url = "http://";
}
$output .= "[url="]".stripslashes($single_comment_arr[1])."[/url]".$separator;
}
else $output .= $single_comment_arr[1].$separator;
if (fmod($i, $linebreak)==0) $output .= "
";
}
}

}
}
if (fmod($i, $linebreak)=="0") $output = substr($output, 0, -(strlen($separator)+6));
else $output = substr($output, 0, -strlen($separator));
return $output;
}


2. Open shows.inc.php

a. Find:

$output = str_replace("{title}", $news_arr[2], $template_full);

add below:

if(CountComments($news_arr[0], $archive) > 0){
$output = str_replace('[commenters-header]', '', $output);
$output = str_replace('[/commenters-header]', '', $output);
$output = preg_replace("#\{commenters:(.*):(.*)\}#ie", "list_commenters('".$news_arr[0]."', '\\1', '\\2')", $output);
}
else $output = preg_replace("#\[commenters-header\](.*?)\[/commenters-header\]#i", "", $output);


b. Find:

$output = $template_active;


add below:

if(CountComments($news_arr[0], $archive) > 0){
$output = str_replace('[commenters-header]', '', $output);
$output = str_replace('[/commenters-header]', '', $output);
$output = preg_replace("#\{commenters:(.*):(.*)\}#ie", "list_commenters('".$news_arr[0]."', '\\1', '\\2')", $output);
}
else $output = preg_replace("#\[commenters-header\](.*?)\[/commenters-header\]#i", "", $output);


Now you can use [commenters-header]{commenters:N:S}[/commenters-header] in your template (Active News/Full Story) to list the commenters for each article.
N is the number of commenters per line (0 = all in one line) and S is the separator between each commenter.
Everything between [commenters-header] and [/commenters-header] shows only if there is a comment.

For example:

[commenters-header]{commenters:2: - }[/commenters-header]

would show this:

commenter1 - commenter2 -
commenter3 - commenter4
////////////////////////////////////////

Re: [HACK] List all commenters

Kewl hack!!  smile
Gonna try to install it next week or so.
Thnx!

Re: [HACK] List all commenters

Yoooooooooooooooooooooopiii thank you so much , bloggers will love this

Re: [HACK] List all commenters

For poeple who get a message saying
.data/comments.txt file not found

change the path from

$alle_comments = file("./data/comments.txt"); 

To

$alle_comments = file("cutenews/data/comments.txt"); 

where Cutenews put the directory name of your cute news or use the full path that your server give you . like publish/home/www/cutenews/data/comments.txt for example
have fun .
the hack is working very good with me you can take a look http://sad-destiny.w2r.net

Re: [HACK] List all commenters

Well,.... the hack works fine!
Nice job  wink 
Wanna see it working? Click

Re: [HACK] List all commenters

It's not working for me. It just shows the {commenters} tag from where I placed it. Does the hack work with 1.4.0?

Re: [HACK] List all commenters

i dont see why he would make a hack that doesnt work for 1.4

i have a cool addon idea... it would be very awsome if you could have it, each user name would have an alt=
the alt would be a comment that the person posted
so on mouse over it would show what the persons comment is smile

and could you limit how many names it shows? like after the 10th name it would put "..."

Re: [HACK] List all commenters

It doesn't.. I followed what he said and it doesn't work for me.

Re: [HACK] List all commenters

Something else needs to be added.. i put this in the hacks area but did it disappear?

Re: [HACK] List all commenters

Yes,.... you have to add more.

Open shows.inc.php

Find:

$output = $template_active;

And under it you add:

$output = str_replace("{commenters}", list_commenters($news_arr[0]), $output);

Re: [HACK] List all commenters

I'm frustrated. ~_~ I don't know anything about PHP. I added what you included of the coding, Predator, and now I don't even get a {commenters} tag on the page, just a blank line.

Re: [HACK] List all commenters

Did you use the {commenters} tag in your template (Active News)?

Re: [HACK] List all commenters

Yes.

I added it into my Active News template. I've added the PHP coding into functions.inc.php and shows.inc.php and nothing.

Re: [HACK] List all commenters

Hmm,... strange it wont work then.
Maybe the maker of this hack (FI-DD) can help you out?
I dont know what else i can tell you to help you out, sorry.