Powered by MediaWiki
Personal tools

Recent comments in the sidebar

From b2evolution manual

Jump to: navigation, search

This manual page is outdated. NEW PAGE: Recent Comments In The Sidebar in b2evolution v5+.

[edit] Recent comments plugin

The easiest way to accomplish this is to use the Sidebar comments plugin.

[edit] For version 1.8.1

Make a new file in 'your skin' directory and call it whatever you want (in my example _includecomments.php)

the content of that file (here I want to show 5 comments)

 <?php
 if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

 $CommentList = & new CommentList( $blog, "'comment'", array('published'), '',	'',	'DESC',	'',	5 );
 $CommentList->display_if_empty( '<div class="bComment"><p>'.T_('No comment yet...').'</p></div>' );

	
	while( $Comment = $CommentList->get_next() )
	{	// Loop through comments:
		$Comment->get_Item();	?>
		<!-- ========== START of a COMMENT ========== -->
		<a name="c<?php $Comment->ID() ?>"></a>
		<div class="bCommentinclude">
			<div class="bCommentText">
			<?php $Comment->Item->permanent_link('#title#') ?> : 
			<?php $Comment->author( '', '', '', '', 'htmlbody', true) ?><br />
			<div style="cursor:pointer" onclick='window.location="<?php echo $Comment->get_permanent_url(); ?>"'><?php $Comment->content(); ?></div>
			</div>
		</div>
		<!-- ========== END of a COMMENT ========== -->
		<?php 
	}	// End of comment loop.
 ?>

in your _main.php file, in the sidebar (or where-ever you want to put those comments, you put this :

<div class="bSideItem">
<h3><?php echo T_('Last Comments') ?></h3>
<?php require( dirname(__FILE__).'/_includecomments.php' );	 ?>
</div>

and add this to your css file

div.bCommentinclude /* Entire comment block */
{ 
	margin: 0ex 2ex 0ex 0;
	padding: 1em 1ex 1em 0;
	height: 4em;
	overflow: hidden;
}
div.bCommentincludeauthor /* Entire comment block */
{ 
	font-size: 0.9em;
	width:200px;
	height: 1.3em;
	overflow: hidden;
}

[edit] For version 0.9.1

Make a new file in 'your skin' directory and call it whatever you want (in my example _includecomments.php)

the content of that file (here I want to show 5 comments)

<?php
	
	if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );

	
	$CommentList = & new CommentList( $blog, "'comment'", $show_statuses, '',	'',	'DESC',	'',	5 );
	
	$CommentList->display_if_empty( '<div class="bComment"><p>'.T_('No comment yet...').'</p></div>' );

	while( $Comment = $CommentList->get_next() )
	{	// Loop through comments:	?>
		<!-- ========== START of a COMMENT ========== -->
		<a name="c<?php $Comment->ID() ?>"></a>
		<div class="bCommentinclude">
			<div class="bCommentText">
			<?php $Comment->author( '', '', '', '', 'htmlbody', true) ?><br />
			<a href="<?php $Comment->Item->permalink() ?>"><?php $Comment->Item->title( '', '', false ) ?> : 
				<?php $Comment->content() ?></a>
			</div>
		</div>
		<!-- ========== END of a COMMENT ========== -->
		<?php 
	}	// End of comment loop.
?>

in your _main.php file, in the sidebar (or where-ever you want to put those comments, you put this :

<div class="bSideItem">
<h3><?php echo T_('Last Comments') ?></h3>
<?php require( dirname(__FILE__).'/_includecomments.php' );	 ?>
</div>[/code]

and add this to your css file
[code]div.bCommentinclude /* Entire comment block */
{ 
	margin: 0ex 2ex 0ex 0;
	padding: 1em 1ex 1em 0;
	height: 4em;
	overflow: hidden;
}
div.bCommentincludeauthor /* Entire comment block */
{ 
	font-size: 0.9em;
	width:200px;
	height: 1.3em;
	overflow: hidden;
}