- b2evolution CMS User Manual
- Developer Reference
- How to... (Customize)
- Display Recent Posts In The Sidebar
Display Recent Posts In The Sidebar
b2evo 2.x and above
Using the widgets system, you should add to your sidebar container a Post list widget. In 3.x series you can use the Simple Post list widget to include the recent posts from the blog itself, and the Universal Items List widget to include recent posts from another blog.
before b2evo 2.x
The easiest method to accomplish this is the use the Sideblog plugin, which works in b2evolution 1.6 and up.
All the code in this examples shows the title with a link to the post, but also the content itself is a link
Show the latest post from categoy 5 in blog 3
<div class="bSideItem">
<?php $BlogBList = & new ItemList( 3, '', '', '', '', '', array(5), '', 'DESC', '', 1, '', '', '', '', '', '', '', 'posts' );
while( $Item = $BlogBList->get_item() ) { ?>
<strong><?php $Item->permanent_link('#title#'); ?></strong>
<div style="cursor:pointer" onclick='window.location="<?php echo $Item->get_permanent_url(); ?>"'>
<?php $Item->content(1,false,'#','#','#','#','htmlattr'); ?>
</div>
<?php } ?>
</div>
Show the latest post from category 7,37,38,39 in blog 3 (ideal if you use subcategories)
<div class="bSideItem">
<?php $BlogBList = & new ItemList( 3, '', '', '', '', '', array(7,37,38,39), '', 'DESC', '', 1, '', '', '', '', '', '', '', 'posts' );
while( $Item = $BlogBList->get_item() ) { ?>
<strong><?php $Item->permanent_link('#title#'); ?></strong>
<div style="cursor:pointer" onclick='window.location="<?php echo $Item->get_permanent_url(); ?>"'>
<?php $Item->content(1,false,'#','#','#','#','htmlattr'); ?>
</div>
<?php } ?>
</div>
Show the latest post from blog 5, whatever category
<div class="bSideItem">
<?php $BlogBList = & new ItemList( 5, '', '', '', '', '', array(), '', 'DESC', '', 1, '', '', '', '', '', '', '', 'posts' );
while( $Item = $BlogBList->get_item() ) { ?>
<strong><?php $Item->permanent_link('#title#'); ?></strong>
<div style="cursor:pointer" onclick='window.location="<?php echo $Item->get_permanent_url(); ?>"'>
<?php $Item->content(1,false,'#','#','#','#','htmlattr'); ?>
</div>
<?php } ?>
</div>