Okay so this is kinda neat. It sorts posts by blog kinda like a linkblog does with categories. Throw this into your skins/skinname folder as whateveryoulike.php then do a require on whateveryoulike.php in your _main.php. Customizability exists in the upper top half. You know what I mean so stop it!
<?php
/* An improved drab little snoogle by EdB - {@link http://wonderwinds.com}
*
* b2evolution - {@link http://b2evolution.net/}
* Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
* @copyright (c)2003-2004 by Francois PLANQUE - {@link http://fplanque.net/}
*
* Version 3: where we list recent posts by blog instead of as a big lump 'o posts
*
* @package evoskins
* @subpackage YOUR_SKIN_NAME
*/
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );
# You can customize the following as you wish:
# maximum number of recentpost entries to display:
$recpo_limit = 8;
# exclude the current blog from the list?
$recpo_exclude_current = true;
# The next block of stuff is the Topanga special selection section You
# can include or exclude a list of blogs, or both if you're into it.
# EXCLUDE other blogs from the list?
$recpo_use_exclude = true;
# INCLUDE other blogs from the list?
$recpo_use_include = true;
# this is a comma-separated array for EXCLUDING blogs, like '1,2,4,99'
$recpo_exclude_blogs = '4,7';
# this is a comma-separated array for INCLUDING blogs, like '1,2,4,99'
$recpo_include_blogs = '2,5,8';
# recentpost global delimiters:
$recpo_main_start = '<div class="bSideItem"><h3>Recent Posts</h3>';
$recpo_main_end = "</div>\n";
# recentpost item delimiters:
$recpo_blog_before = '<h4>';
$recpo_blog_after = "</h4>\n";
# recentpost item delimiters:
$recpo_item_before_all = '<ul>';
$recpo_item_before = '<li>';
$recpo_item_after = "</li>\n";
$recpo_item_after_all = "</ul>\n";
# show post issue date?
$recpo_date = true;
# date format of '' is blog default. Go to your back office settings|regional
# tab and click 'Create new locale' to learn all the groovy format options
$recpo_date_fmt = '';
# If 'recpo_foo' is false then 'recpo_foo_link' doesn't matter.
# show and link post author?
$recpo_author = true;
$recpo_author_link = true;
# show and link post category?
$recpo_category = true;
$recpo_category_link = true;
# show and link number of comments?
# using this makes an extra query per post - kinda heavy on the server...
$recpo_comments = true;
$recpo_comments_link = true;
# these 3 matter if _date or _author or _category or _comments is true
# recentcomment show number class:
$recpo_before_class = ' <em>';
$recpo_class = 'dimmed';
$recpo_after_class = '</em>';
// --- you must be 21 to enter (ID required) --- //
// --- No Cover! --- No Minimum! --- //
echo $recpo_main_start;
$sql = "SELECT blog_ID, blog_shortname, blog_name FROM $tableblogs";
$list_o_blogs = $DB->get_results($sql);
foreach ( $list_o_blogs as $a_blog ) {
if( $recpo_use_exclude ) {
$exclude_blogs = explode(",", $recpo_exclude_blogs);
if(in_array($a_blog->blog_ID, $exclude_blogs)) {
continue;
}
}
if( $recpo_use_include ) {
$include_blogs = explode(",", $recpo_include_blogs);
if(! in_array($a_blog->blog_ID, $include_blogs)) {
continue;
}
}
if( $recpo_exclude_current && ($a_blog->blog_ID == $blog) ) {
continue;
}
$this_blog = $a_blog->blog_ID;
$this_name = $a_blog->blog_name;
$this_shortname = $a_blog->blog_shortname;
$NewBlog = Blog_get_by_ID( $this_blog );
$server_time = date("Y-m-d h:i:s", time() + ($Settings->get('time_difference') * 3600) );
echo $recpo_blog_before; ?>
<a href="<?php $NewBlog->disp( 'blogurl', 'raw' ) ?>" title="<?php echo $this_name ?>"><?php echo $NewBlog->disp( 'shortname', 'htmlbody' ) ?></a>
<?php echo $recpo_blog_after;
$posts_shown = 0;
$sql = "SELECT ID, post_title, post_issue_date, cat_ID, cat_name, cat_blog_ID FROM $tableposts JOIN $tablecategories ON ( post_category = cat_ID) WHERE post_status = 'published' AND cat_blog_ID = $this_blog AND post_issue_date <= '$server_time' ORDER BY post_issue_date DESC";
$results = $DB->get_results($sql);
if ($results) {
echo $recpo_item_before_all;
foreach ($results as $result) {
$posts_shown = ($posts_shown+1);
if( $posts_shown > $recpo_limit ) {
break;
}
$post_title = stripslashes($result->post_title);
$title = htmlspecialchars(stripslashes($result->post_title));
$this_post = $result->ID;
$NewItem = Item_get_by_ID( $this_post );
$permalink = $NewItem->gen_permalink( '', '', false, '&' );
if( $recpo_author || $recpo_category ) {
$this_blog = $result->cat_blog_ID;
$NewBlog = Blog_get_by_ID( $this_blog );
}
echo $recpo_item_before;
echo '<a href="'.$permalink.'" title="link to '.$post_title.' post">'.$title.'</a>';
$closing_bit = '';
$count_comments = 0;
if( $recpo_comments ) {
$query = "SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $this_post";
$count_comments = $DB->get_var($query);
$comment_link = $permalink.'#comments';
}
if( $recpo_date || $recpo_author || $recpo_category || ($count_comments > 0) ) {
$closing_bit = ' <span class="'.$recpo_class.'">(';
}
if( $recpo_date ) {
$post_date = $NewItem->get( 'issue_date' );
if( $recpo_date_fmt == '' ) {
$post_date = mysql2date( locale_datefmt(), $post_date, false);
} else {
$post_date = mysql2date( $recpo_date_fmt, $post_date, false);
}
$closing_bit .= 'Posted ';
$closing_bit .= $post_date;
if( $recpo_author || $recpo_category || $count_comments ) {
$closing_bit .= ', ';
}
}
if( $recpo_author ) {
$auth_id = $NewItem->Author->get('ID');
$auth_name = $NewItem->Author->get('preferedname');
if( $recpo_author_link ) {
$auth_link = '<a href="'.$NewBlog->get( 'blogurl', 'raw' ).'?author='.$auth_id.'" title="Browse all posts by this author">'.$auth_name.'</a>';
$closing_bit .= 'by '.$auth_link;
} else {
$closing_bit .= 'by '.$auth_name;
}
if( $recpo_category || $count_comments ) {
$closing_bit .= ', ';
}
}
if( $recpo_category ) {
$cat_id = $result->cat_ID;
$cat_name = $result->cat_name;
if( $recpo_category_link ) {
$cat_link = '<a href="'.$NewBlog->get( 'blogurl', 'raw' ).'?cat='.$cat_id.'" title="Browse all posts in this category">'.$cat_name.'</a>';
$closing_bit .= 'in '.$cat_link;
} else {
$closing_bit .= 'in '.$cat_name;
}
if( $count_comments ) {
$closing_bit .= ', ';
}
}
if( $count_comments ) {
if( $recpo_comments_link ) {
$closing_bit .= '<a href="'.$comment_link.'" title="link to last comment on '.$post_title.' post">';
$closing_bit .= $count_comments.' comments</a>';
} else {
$closing_bit .= $count_comments.' comments';
}
}
if( $closing_bit ) {
$closing_bit .= ')</span>';
}
echo $recpo_before_class.$closing_bit.$recpo_after_class;
echo $recpo_item_after;
}
echo $recpo_item_after_all;
}
} // end the big blog foreach
echo $recpo_main_end;
?>
Just tested it.
It works great.
But too good.
It's also showing blogs that I mentioned not to show in the bloglist.
I can put those blogs in the exclude list offcourse, it's just double the work.
It would be good to have the opposide arround as a choise.
If I have 30 blogs, and I only want to show 2 or 3, than I have 26 to exclude...
It's also showing future posts. And that is not supposed to happen, if I have 'history' blog, like it is not suppose to happen that it will show history posts if I have an event calander.
It should look at the timestamp-things in stubfile.. I think...