- b2evolution CMS Support Forums
- b2evolution Support
- FAQ
- A comment-teaser in the sidebar
1 topanga May 16, 2005 14:33
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;
}