Recent Topics

1 Jan 11, 2008 13:28    

My b2evolution Version: 2.x

I want to set up a skin to have alternating styles for every other comment just in case I get, you know, comments ;)

If I understand correctly the skin_include() function can set some params, which are then "array_merged" with the default params in _item_feedback.inc.php. That's cool, but I want to change the comment_start param after each comment is displayed. Something like

if( $params['comment_start'] == '<div class="bComment">' ) {
	set_my_comment_start_param_to( '<div class="bCommentAlternate">' );
	} else {
	set_my_comment_start_param_to( '<div class="bComment">' );
	}

added to the "while( $Comment = & $CommentList->get_next() )" bit, but there is no "set_my_comment_start_param_to" function.

(already been covered? please point as I was unable to find it on my own)

2 Jan 11, 2008 14:35

Figured it out!

if( $params['comment_start'] == '<div class="bComment">' ) {
	$params['comment_start'] = '<div class="bCommentAlt">';
	} else {
	$params['comment_start'] = '<div class="bComment">';
	}

It's not in the while bit yet, but I don't see that as being much of a challenge.

[url=http://www.mythicsoft.com/agentransack/]Agent Ransack[/url] almost always solves the mystery :)

3 Jan 11, 2008 15:18

Here's what Topanga did with the first version of her new skin ( I think it's been updated a bit though)
Alternating colors plus numbers :)

$CommentList = & new CommentList( NULL, implode(',', $type_list), array('published'), $Item->ID, '', 'ASC' );
?>

<ol class="commentlist">
<?php
	/* This variable is for alternating comment background */
		$oddcomment = 'alt';
	/**
	 * @var Comment
	 */
	while( $Comment = & $CommentList->get_next() )
	{	// Loop through comments:
		?>
		<!-- ========== START of a COMMENT/TB/PB ========== -->
		<?php $Comment->anchor() ?>
		<li id="comment-<?php $Comment->ID(); ?>" class="<?php echo $oddcomment; ?>">
			
			<?php
				switch( $Comment->get( 'type' ) )
				{
					case 'comment': // Display a comment:
						$Comment->permanent_link( '§ ' );
						$Comment->author('','','','®','htmlbody',true);
						$Comment->msgform_link( $Blog->get('msgformurl') );
						
						echo ' '.T_('said on :').' <small class="commentmetadata">';
						$Comment->date() ?> @ <?php $Comment->time( 'H:i' ); $Comment->edit_link( '','',get_icon( 'edit' ) ); $Comment->delete_link( '','',get_icon( 'delete' ) ); echo '</small>';
						break;

					case 'trackback': // Display a trackback:
						$Comment->permanent_link( T_('Trackback') );
						echo ' '.T_('from:').' ';
						$Comment->author( '', '#', '', '#', 'htmlbody', true );
						break;

					case 'pingback': // Display a pingback:
						$Comment->permanent_link( T_('Pingback') );
						echo ' '.T_('from:').' ';
						$Comment->author( '', '#', '', '#', 'htmlbody', true );
						break;
				}
			?>
			
			<?php $Comment->rating(); ?>
			<div class="bCommentText">
				<?php $Comment->content() ?>
			</div>
			<div class="bCommentSmallPrint">
				

				
			</div>
		</li>
		<?php /* Changes every other comment to a different class */
		if ('alt' == $oddcomment) $oddcomment = '';
		else $oddcomment = 'alt';
	?>

4 Jan 13, 2008 06:52

EdB, what did you end up doing with

if( $params['comment_start'] == '<div class="bComment">' ) {
   $params['comment_start'] = '<div class="bCommentAlt">';
   } else {
   $params['comment_start'] = '<div class="bComment">';
   }


I see you have it working.

5 Jan 13, 2008 07:27

Step one was to copy _item_feedback.inc.php from skins/ to skins/evopress/ folder. I did not rename the skin so I will be extra careful when I upgrade with the next release.

In the original file you will find the following around line 162:

	while( $Comment = & $CommentList->get_next() )
	{	// Loop through comments:

		// ------------------ COMMENT INCLUDED HERE ------------------
		skin_include( $params['comment_template'], array(
				'Comment'              => & $Comment,
			  'comment_start'        => $params['comment_start'],
			  'comment_end'          => $params['comment_end'],
			) );
		// Note: You can customize the default item feedback by copying the generic
		// /skins/_item_comment.inc.php file into the current skin folder.
		// ---------------------- END OF COMMENT ---------------------

	}	// End of comment list loop.


In my new version I have the following:

	while( $Comment = & $CommentList->get_next() ) {
		skin_include( $params['comment_template'], array(
				'Comment' => & $Comment,
			  'comment_start' => $params['comment_start'],
			  'comment_end' => $params['comment_end'],
			) );
		if( $params['comment_start'] == '<div class="bComment">' ) {
			$params['comment_start'] = '<div class="bComment altcomment">';
			} else {
			$params['comment_start'] = '<div class="bComment">';
			}
		}

I then added a definition of ".altcomment" to my style sheet to give it a tiny bit of gray background.

I gave some thought to numbering comments but opted to not because it would mean making sure they looked good. At the time I also thought it would be cool to count comments and after 5 put in a visual break of some sort, but didn't do more than think about it.

PS: the "basin" skin had the coolest one line trick for figuring out if it was odd or even so it could do alternating post colors, but I settled for sloppy ugly line-heavy "if this then that else the other thing".

6 Jan 13, 2008 08:11

Thanks mate, it's clean, lean and looks great on your site


Form is loading...