- b2evolution CMS Support Forums
- b2evolution Support
- General Support
- [2.x] summary hack by year - solved
1 xerxes Oct 29, 2009 01:18
My b2evolution Version: 2.x
Is it possible to have the summary page lists all the posts per specific year?
so i would have a summary_2009.php, then another file that list only 2008 posts. currently it lists all posts by year and month.
wondering if there is any filters in this code to specify year?
$BlogBList = & new ItemList2( $l_Blog, NULL, 'now', 0 );
2009
10/1/2009 - blog title - blog link
8/2/2009 - blog title - blog link
2008
2/3/2008 - blog title - blog link
Code I'm using from yabba's hack awhile ago. Thanks Yabba!
<?php // --------------------------- BLOG LIST -----------------------------
load_class('items/model/_itemlist.class.php');
$BlogCache = & get_Cache( 'BlogCache' );
$blog_array = $BlogCache->load_public( 'ID' );
foreach( $blog_array as $blog )
{ // Loop through all public blogs:
# by uncommenting the following lines you can hide some blogs
if( $blog == 1 ) continue; // Hide blog 1...
if( $blog == 2 ) continue; // Hide blog 2...
if( $blog == 4 ) continue; // Hide blog 4...
/**
* @var Blog
*/
$l_Blog = & $BlogCache->get_by_ID( $blog );
?>
<?php // Get the all posts for each blog:
$BlogBList = & new ItemList2( $l_Blog, NULL, 'now', 0 );
$BlogBList->set_filters( array(
'order' => 'DESC',
'unit' => 'posts',
) );
$curr_year = 0; //user modified
$curr_month = 0; //user modified
// Run the query:
$BlogBList->query();
while( $Item = & $BlogBList->get_item() )
{
?>
<?php
if( empty( $curr_month ) || $curr_month != date( 'm', mysql2timestamp( $Item->get( 'issue_date' ) ) ) )
{ // month change
if( $curr_month != 0)
{
echo '</table>';
}
$curr_year = date( 'Y', mysql2timestamp( $Item->get( 'issue_date' ) ) );
$curr_month = date( 'm', mysql2timestamp( $Item->get( 'issue_date' ) ) ) ;
echo '<tr><th colspan="2">'.date( 'M', mysql2timestamp( $Item->get( 'issue_date' ) ) ).' '.$curr_year.'</th></tr><tr><td><table class="news_blue">';
}
?>
<tr><td lang="<?php $Item->lang() ?>">
<?php
$Item->issue_date( array(
'before' => ' ',
'after' => ' ',
'date_format' => '#',
) );
?></td>
<td width="100%"><?php
$Item->title( array(
'link_type' => 'permalink',
) );
?></td></tr>
<?php
}
?>
[/code]
stepping back for a bit works wonders. Just create several files or create a variable to pickup in the http get. be sure to filter the data and make it safe before using that variable.
add this before
then add the extra closing bracket