Recent Topics

1 Apr 07, 2007 12:15    

My b2evolution Version: Not Entered

I'm using the custom skin, I want to know how to alternate the background colours from one post to the next, to help make the posts stand apart from the next one, so the first post is white background, the second post is grey, the third is white, 4th grey etc.

2 Apr 07, 2007 12:22

crack open _main.php and find a section that looks like this :

<?php
	// ------------------------------------ START OF POSTS ----------------------------------------
	if( isset($MainList) ) $MainList->display_if_empty(); // Display message if no post

	if( isset($MainList) ) while( $Item = & $MainList->get_item() )
	{
	?>

	<?php
		//previous_post();	// link to previous post in single page mode
		//next_post(); 			// link to next post in single page mode
	?>

	<?php 
		$MainList->date_if_changed();
	?>

	<div class="bPost bPost<?php $Item->status( 'raw' ) ?>" lang="<?php $Item->lang() ?>">

and change it to look like this :

<?php
	// ------------------------------------ START OF POSTS ----------------------------------------
$toggle = false;
	if( isset($MainList) ) $MainList->display_if_empty(); // Display message if no post

	if( isset($MainList) ) while( $Item = & $MainList->get_item() )
	{
	?>

	<?php
		//previous_post();	// link to previous post in single page mode
		//next_post(); 			// link to next post in single page mode
	?>

	<?php 
		$MainList->date_if_changed();
	?>

	<div class="bPost bPost<?php $Item->status( 'raw' ) ?> <?php echo ( ( $toggle = !$toggle ) ? 'odd' : 'even' ); ?>" lang="<?php $Item->lang() ?>">

Then in custom.css add the new classnames :

.odd{
background-color:#fff;
color:inherit;
}

.even{
background-color:#ddd;
color:inherit;
}

¥

3 Apr 07, 2007 12:53

Ahhh thats Fantastic ¥åßßå, it worked like a charm! Thanks so much

4 Apr 07, 2007 15:09

[url=http://www.akdingo.com/blogs/]My page is here...[/url]

Now that I have fixed the backgrounds, I would like to put all the posts from one date into their own div tags, to add a gap between one date and the next.

I tried adding a few divs and styles in css but it broke the whole design.
I imagine it's got something to do with $MainList->date_if_changed();

5 Apr 07, 2007 15:34

If you only want a gap then you don't need a div :

<?php
if( empty( $first_post ) )
{
        $MainList->date_if_changed();
        $first_post = true;
}
else
{
        $MainList->date_if_changed( '<h2 style="margin-top:2em">');
}
?>

Just change the 2em until you get the gap you want.

¥

6 Apr 07, 2007 15:43

thanks. That looks much neater, but I would prefer to end the current div tag and start a new div when the date changes... to look similar to [url=http://www.akdingo.com/dingoes/index.php]here[/url]. I still have to figure out the css to keep those div tags lined up on the right too... but thats not a prob for here

7 Apr 07, 2007 15:49

<?php
if( empty( $first_post ) )
{
        $MainList->date_if_changed( '<div><h2>');
        $first_post = true;
}
else
{
        $MainList->date_if_changed( '</div><div><h2>');
}
?>



.........

	<?php
	} // ---------------------------------- END OF POSTS ------------------------------------
echo ( empty( $first_post ) ? '' : '</div>' );
?>

Should do it

¥

8 Apr 07, 2007 16:16

Thanks. I've played with it without success, but it's late so I will try again tomorrow. The code you gave does work, I saw the page source. I'm just having probs with the css.

9 Apr 10, 2007 16:33

I got that div trick to work, thanks. but I came up with another error and ended up starting from scratch. will post in a new post

10 Apr 25, 2007 15:27

How about comments? How would I make the comments alternate background colors? Or make my own comments look different than the rest?

11 Apr 25, 2007 15:44

For comments it's pretty similar, crack open _feedback.php and add the new bits :

	<?php
$toggle = false; // add this line


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

	$CommentList->display_if_empty(
								'<div class="bComment"><p>' .
								sprintf( /* TRANS: NO comments/trackabcks/pingbacks/ FOR THIS POST... */
													T_('No %s for this post yet...'), implode( "/", $disp_title) ) .
								'</p></div>' );

	while( $Comment = & $CommentList->get_next() )
	{	// Loop through comments:
		?>
		<!-- ========== START of a COMMENT/TB/PB ========== -->
		<?php $Comment->anchor() ?>


<!-- amend the following line -->
		<div class="bComment <?php echo ( ( $toggle = !$toggle ) ? 'odd' : 'even' ); ?>">

To style your own comments differently just change this line instead :

	<div class="bComment <?php echo ( empty( $Comment->author_user_ID ) ? '' : 'author_'.$Comment->author_user_ID ); ?>">

And then add the styles for each author to your css :

.author_1{
background:#fff;
color:#f00;
}


Change 1 to tally with the actual author id.

¥

12 Apr 25, 2007 16:05

Awesome. You rock! Thanks for the help...


Form is loading...