List entries with most comments?
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    b2evolution Forum Index -> Plugins & Extensions -> Request a Plugin or Hack
View previous topic :: View next topic  
Author Message
MarcDK
Hooked :)
Hooked :)

Joined: 29 Mar 2005
Posts: 131
Reputation: 54.1Reputation: 54.1Reputation: 54.1Reputation: 54.1Reputation: 54.1 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 1

PostPosted: Wed Dec 21, 2005 12:02    Post subject: List entries with most comments? Reply with quote

See subject: Is it possible to show up the 10 or 5 entries with the most comments? That would really be nice. =)
Back to top
View user's profile Send private message
personman
SuperGuru
SuperGuru

Joined: 09 Feb 2005
Posts: 2178
Reputation: 116.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 15

PostPosted: Wed Dec 21, 2005 14:32    Post subject: Reply with quote

That's a great idea. It can be done fairly easily with a plugin. I've got one started. I may move this thread to the plugin request forum if you don't mind.
_________________
RTFM
Back to top
View user's profile Send private message Visit poster's website
MarcDK
Hooked :)
Hooked :)

Joined: 29 Mar 2005
Posts: 131
Reputation: 54.1Reputation: 54.1Reputation: 54.1Reputation: 54.1Reputation: 54.1 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 1

PostPosted: Wed Dec 21, 2005 16:56    Post subject: Reply with quote

Thanx a lot =)
Back to top
View user's profile Send private message
EdB
/bb|[^b]{2}/

Joined: 05 Jan 2004
Posts: 7123
Reputation: 140.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 90

PostPosted: Wed Dec 21, 2005 18:18    Post subject: Reply with quote

Way back in the day there was a hack that did this. A plugin for the phoenix generation would be cool.

PS: moved this to plugins request.
Back to top
View user's profile Send private message
personman
SuperGuru
SuperGuru

Joined: 09 Feb 2005
Posts: 2178
Reputation: 116.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 15

PostPosted: Wed Dec 21, 2005 18:25    Post subject: Reply with quote

I've got something underway. I have a question, though. Here's the code I'm using:

Code:
        $list = new ItemList($blog, array(), '', '', -1, '', array(),
         '', 'DESC', 'comments', 30);


I'm telling it to order by 'comments'. But is that looking at the number of comments for the post, or the comment status of the post (open, closed or disabled)? I was hoping for the former, but it appears to be the latter. If this doesn't work then will I have to build a query (more likely queries) from scratch to get all post ids for the blog, then count the number of comments that match their ids?

EdB, if you can find the old hack I'd like to take a look at it.

_________________
RTFM
Back to top
View user's profile Send private message Visit poster's website
EdB
/bb|[^b]{2}/

Joined: 05 Jan 2004
Posts: 7123
Reputation: 140.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 90

PostPosted: Wed Dec 21, 2005 19:14    Post subject: Reply with quote

I just changed my sig file but it doesn't seem to be showing up. I wonder why that is? I wonder if characters inside links count against the 255 max, and if so why did it not truncate my new sig file?

http://forums.b2evolution.net/viewtopic.php?t=2682 is one though I think it was very version-specific.

http://forums.b2evolution.net/viewtopic.php?t=4808 links to two others though I didn't follow those links.

http://forums.b2evolution.net/viewtopic.php?t=6189 is probably something you're already hip to eh?
Back to top
View user's profile Send private message
personman
SuperGuru
SuperGuru

Joined: 09 Feb 2005
Posts: 2178
Reputation: 116.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 15

PostPosted: Wed Dec 21, 2005 20:21    Post subject: Reply with quote

Those threads are about showing recent comments. I want to show links to the posts that have the most number of comments.
_________________
RTFM
Back to top
View user's profile Send private message Visit poster's website
EdB
/bb|[^b]{2}/

Joined: 05 Jan 2004
Posts: 7123
Reputation: 140.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 90

PostPosted: Wed Dec 21, 2005 20:28    Post subject: Reply with quote

The details always mess me up!

Most heavily commented would be a unique animal. A good one too! Drive traffic to that which your readers found interesting and you create this global warming type of situation, only a good global warming: not the bad one that ruins the earth and puts snow shovel salesmen out of business.
Back to top
View user's profile Send private message
personman
SuperGuru
SuperGuru

Joined: 09 Feb 2005
Posts: 2178
Reputation: 116.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 15

PostPosted: Thu Dec 22, 2005 15:51    Post subject: Reply with quote

I have this almost working. I had to cobble together a big, gnarly SQL query with joins and what not, but it does spit out the post titles and their comment counts. And you can limit it to the top x posts, where x is a number you enter with a plugin param. The default is 5. You can see it here:

http://www.brendoman.com/dev/blogs/index.php

Now I've got to figure out how to generate the permalink url from outside the Item class. There's also a bug for posts that appear on more than one blog. The comments seem to get counted for each blog sometimes.

Here's the meat of the code, for those of you keeping score at home (of for anyone who wants to help):

Code:
                $sql = "SELECT DISTINCT post_ID , post_title ,
                COUNT(post_ID ) AS count
                FROM evo_comments , evo_posts
                INNER JOIN evo_postcats ON post_ID = postcat_post_ID
                INNER JOIN evo_categories ON postcat_cat_ID = cat_ID
                WHERE evo_posts.post_ID = evo_comments.comment_post_ID
                and (cat_blog_ID = ".$params['blog'].")
                group by post_ID  ORDER BY `count`  DESC
                LIMIT ".$params['limit'];
                $results = $DB->get_results($sql);
                for ($i = 0; $i < $params['limit']; $i++) {
                        if ($results[$i]->count == '') break;
                        echo $results[$i]->post_title;
                        echo ' ('.$results[$i]->count.')<br />';
                }




If anyone wants, I can give you the full plugin file so you can play with it.

_________________
RTFM
Back to top
View user's profile Send private message Visit poster's website
personman
SuperGuru
SuperGuru

Joined: 09 Feb 2005
Posts: 2178
Reputation: 116.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 15

PostPosted: Sat Dec 24, 2005 10:51    Post subject: Reply with quote

Got it! It's working now, permalinks and all. Same link as above. I'll clean it up and make a post about it. Then I'll see about a backport to 0.9.1 (as a hack) if you're still using it, MarcDK
_________________
RTFM
Back to top
View user's profile Send private message Visit poster's website
personman
SuperGuru
SuperGuru

Joined: 09 Feb 2005
Posts: 2178
Reputation: 116.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 15

PostPosted: Sat Dec 24, 2005 11:12    Post subject: Reply with quote

Here's the plugin:

http://forums.b2evolution.net/...hp?p=30947

_________________
RTFM


Last edited by personman on Sat Dec 24, 2005 12:18; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
personman
SuperGuru
SuperGuru

Joined: 09 Feb 2005
Posts: 2178
Reputation: 116.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 15

PostPosted: Sat Dec 24, 2005 12:13    Post subject: Reply with quote

Here's the backport for b2evolution 0.9.x. Grab the file below and paste that into your skin. You can edit the default params if you want. Not as pretty as a plugin, but it works.

http://www.brendoman.com/media...tshack.txt

_________________
RTFM
Back to top
View user's profile Send private message Visit poster's website
MarcDK
Hooked :)
Hooked :)

Joined: 29 Mar 2005
Posts: 131
Reputation: 54.1Reputation: 54.1Reputation: 54.1Reputation: 54.1Reputation: 54.1 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 1

PostPosted: Sun Dec 25, 2005 15:08    Post subject: Reply with quote

I'm sorry but it does not work correctly for me. The first item has 132 comments. In reality it only has 44. This means he multiplies it with 3.

Any idea?

UPDATE: it also multiplies the third place two times which means that the 35 comments are becoming 70.

UPDATE 2: Ok it seems that every item in this list generated by this script has wrong numbers. The last one is also multiplied with 3 and so is the 4th one. Ony the second one is correct showing 117 comments which is correct. =(
Back to top
View user's profile Send private message
personman
SuperGuru
SuperGuru

Joined: 09 Feb 2005
Posts: 2178
Reputation: 116.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 15

PostPosted: Mon Dec 26, 2005 17:16    Post subject: Reply with quote

Hmm, do those posts appear on more than one blog? That's a known bug. Do they appear in more than one category? What about the one that works, is it just in one category?
_________________
RTFM
Back to top
View user's profile Send private message Visit poster's website
MarcDK
Hooked :)
Hooked :)

Joined: 29 Mar 2005
Posts: 131
Reputation: 54.1Reputation: 54.1Reputation: 54.1Reputation: 54.1Reputation: 54.1 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 1

PostPosted: Mon Dec 26, 2005 18:03    Post subject: Reply with quote

Yes, many of my articles appear in more than one category. =/

Can't we just count the categories of an article and divide the number through that?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    b2evolution Forum Index -> Request a Plugin or Hack All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2


 
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
b2evolution Support Forum RSS Feed Forums powered by php Bulletin Board