View Single Post
  #1  
Old 09-25-2009, 11:22 AM
  Hyperdelicious's Avatar 
Hyperdelicious Hyperdelicious is offline
 

Senior Member
  
Join Date: Sep 2002
Location: In the Middle of Nowhere
Posts: 138
 

Default Using foreach, how do you alternate product list Div's background color

On the product list page... I would like products to appear with alternating background colors.. searched the forums but not finding a quick solution... the code is for products_list.tpl here is the snippet of code I'd like to edit:

<div class="products products-list">
{foreach from=$products item=product}

{assign var="url" value="product.php?productid=`$product.productid`& amp;cat=`$cat`&amp;page=`$navigation_page`"}
{if $featured eq 'Y'}
{assign var="url" value=$url|cat:"&amp;featured=Y"}
{/if}

<div class="item" style="background:#F9F0E9;text-align:center;vertical-align:middle;">

I'm thinking it should be as simple as creating an IF statement and adding some sort of array to determine odd even variable... sliding the IF variable=array show DIVx ELSE show DIVy... any ideas?
Reply With Quote