Post details: b2evo: Last commented posts
2004-08-15
b2evo: Last commented posts
Wrote code to display a box with last commented posts in b2evolution.
Simple, yet useful thing - displays a list of posts that have been commented last. Each post is displayed only once, a number after a post indicates how many comments it currently has.
To add this feature, you will need to download code of _commentbox.php and place it in the blogs/skins directory.
In the _main.php of your skin (I used fplanque2002) add this code in the location where you want to see the comment box:
require get_path('skins').'/_commentbox.php';
Changes needed to _class_comment.php:
In class member variables list:
var $num_comm;In the constructor Comment right after comment carma assignment:
$this->num_comm = $db_row['num_comm'];
To the constructor _class_commentlist.php:
In the constructor parameters list add 1 more parameter:
$init_what_to_show = '', $group_by_post = false ) // group comments by post_ID and count the number of posts in num_comm"improve" query:
if( $group_by_post ) $this->request = "SELECT DISTINCT count(*) num_comm, comment_post_ID, max(comment_date) comment_date, ID, post_title "; else $this->request = "SELECT DISTINCT $tablecomments.* ";and add grouping instructions BEFORE the ORDER BY instructions:
if( $group_by_post ) $this->request .= " GROUP BY $tablecomments.comment_post_ID ";
That is it. You may download resulting _class_commentlist.php.
However, there is one known bug I could not fix:
If you enter a blog different from default "All blogs", you may notice that a number of comments has doubled or tripled for some posts.
This happens if a post is filed in more than 1 category in the current blog.
It would be the best to just call some imaginary function get_comment_num() which returns the number of comments this post has. I played with generate_ctp_number(), but it did not work for me. If this is fixed, you would not need to modify _class_comment.php any more.
That'll be good if someone can fix this.
Comments, Pingbacks:
Correction - the function (from _functions_comments.php) is called generic_ctp_number(). But it still does not return the number of comments. :(
Yes I do support it.
The blog is being updated now as well.
So - everything's all right. :)
CaptSolo
This post has 13 feedbacks awaiting moderation...
Leave a comment:
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|---|---|---|---|---|---|---|
| << < | > >> | |||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | ||||
Search
Gallery
www.flickr.com
|
Categories
Archives
- February 2011 (1)
- September 2010 (1)
- October 2009 (1)
- March 2009 (2)
- February 2009 (4)
- January 2009 (2)
- December 2008 (2)
- November 2008 (5)
- October 2008 (10)
- August 2008 (1)
- July 2008 (4)
- June 2008 (1)
- More...
- more...

