boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with Automadic Comment Plugger

 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
TheElementWithin



Joined: 05 Apr 2004
Posts: 4

PostPosted: Fri Dec 24, 2004 2:00 am    Post subject: Help with Automadic Comment Plugger Reply with quote

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
View user's profile Send private message
Cyberian75



Joined: 26 Sep 2002
Posts: 1285
Location: Oregon

PostPosted: Fri Dec 24, 2004 5:54 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
TheElementWithin



Joined: 05 Apr 2004
Posts: 4

PostPosted: Fri Dec 24, 2004 5:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
Cyberian75



Joined: 26 Sep 2002
Posts: 1285
Location: Oregon

PostPosted: Fri Dec 24, 2004 6:44 pm    Post subject: Reply with quote

Put...
Code:
ORDER BY comment_author ASC
at the end of the SQL query.
_________________
Michael P.

Back to top
View user's profile Send private message AIM Address
TheElementWithin



Joined: 05 Apr 2004
Posts: 4

PostPosted: Fri Dec 24, 2004 7:21 pm    Post subject: Reply with quote

Thanks so much! Everything works great!
Back to top
View user's profile Send private message
Cyberian75



Joined: 26 Sep 2002
Posts: 1285
Location: Oregon

PostPosted: Fri Dec 24, 2004 7:48 pm    Post subject: Reply with quote

I revised it again. Smile The offset should be incremented by 1 in its recursive call.
_________________
Michael P.

Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group