View previous topic :: View next topic |
Author |
Message |
TheElementWithin
Joined: 05 Apr 2004 Posts: 4
|
Posted: Fri Dec 24, 2004 2:00 am Post subject: Help with Automadic Comment Plugger |
|
|
Code: |
Look below for the final code.
|
I put that into b2template.functions.php and for some reason it dosent disply the correct amout of comments, nor does it disply them in the right spots. Help anyone? I used dodo's comment hack and turned it into a fuction.
Edit: Oh yea, and im calling it with this...
<?php comment_plugger('<br><b>Plugs:</b> ', '0', ' x '); ?>
Last edited by TheElementWithin on Sat Dec 25, 2004 11:13 pm; edited 1 time in total |
|
Back to top |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1285 Location: Oregon
|
Posted: Fri Dec 24, 2004 5:54 am Post subject: |
|
|
Try...
Code: |
function comment_plugger($text='Plugging: ', $offset=0, $separator=' ') {
global $tablecomments, $id;
$post_id = $id - $offset;
$query = mysql_query("SELECT DISTINCT comment_author, comment_author_url FROM $tablecomments WHERE comment_post_ID = '$post_id' ORDER BY comment_author ASC") or die(mysql_error());
if ($query && mysql_num_rows($query) > 0) {
echo $text;
while($row = mysql_fetch_object($query)) {
$author = $row->comment_author;
$url = $row->comment_author_url;
echo (!empty($url)) ? '<a href="'.$url.'" target="_blank">'.$author.'</a>'.$separator : $author.$separator;
}
} else {
comment_plugger($text, $offset + 1, $separator);
}
}
|
_________________ Michael P.

Last edited by Cyberian75 on Fri Dec 24, 2004 8:00 pm; edited 5 times in total |
|
Back to top |
|
 |
TheElementWithin
Joined: 05 Apr 2004 Posts: 4
|
Posted: Fri Dec 24, 2004 5:32 pm Post subject: |
|
|
Ok one thing I just realized is that if you have deleted an entry it won't work for the one after it. Like if you have entry id #1,2,3 and you delete #2; #3 will try and find comments for #2 and they aren't there because it got deleted.
I also want it to not show the text before it if their are no commenters to be plugged, but that’s easy to do. But how can I make them in ABC order? |
|
Back to top |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1285 Location: Oregon
|
Posted: Fri Dec 24, 2004 6:44 pm Post subject: |
|
|
Put... Code: | ORDER BY comment_author ASC | at the end of the SQL query. _________________ Michael P.
 |
|
Back to top |
|
 |
TheElementWithin
Joined: 05 Apr 2004 Posts: 4
|
Posted: Fri Dec 24, 2004 7:21 pm Post subject: |
|
|
Thanks so much! Everything works great! |
|
Back to top |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1285 Location: Oregon
|
Posted: Fri Dec 24, 2004 7:48 pm Post subject: |
|
|
I revised it again. The offset should be incremented by 1 in its recursive call. _________________ Michael P.
 |
|
Back to top |
|
 |
|