By FvanT on
How do i zebra stripe the content in a Block ? So that every line has a seperate CSS class.
Do i need to override a function that creates the block->content ? or is it much simpler ?
How do i zebra stripe the content in a Block ? So that every line has a seperate CSS class.
Do i need to override a function that creates the block->content ? or is it much simpler ?
Comments
Can be easy, can be tricky
Due to the complexity of achieving what you want the traditional way (divs with css classes), I offer a really simple solution:
create a background image for your block: ensure the height of the image is double your line height, and put a different colour in the top and bottom halves of the image. You will need to edit your theme css file to include the background image as the background for the block, and you will probably have to adjust margins and padding to get the background to align properly with your text.
Another way using css and html depends on your block content. If you are only "zebra striping" plain text, you have to use fixed width fonts, use judicious line breaks, then do something like:
zebra striping inside block
I had the same problem..I had to do the zebra striping inside the block ("who's new" , "Recent comments" etc.) which comes from drupal's core module..
for which I added the following code in the function theme_item_list()
$flip = array('even' => 'odd', 'odd' => 'even');
$class = 'even';
$class = $flip[$class];
if (isset($attributes['class'])) {
$attributes['class'] = ' '. $class;
}
else {
$attributes['class'] = $class;
}
Which actually serves the purpose of zebra striping in function theme_table()
it worked for me .. In the output it appended altenate class in
li class="odd"
li class="even"
now I can add alternate background color in different blocks just by selecting the class.