![]() |
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`&page=`$navigation_page`"} {if $featured eq 'Y'} {assign var="url" value=$url|cat:"&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? |
Re: Using foreach, how do you alternate product list Div's background color
Use cycle instead...
Code:
<div class="{cycle values="style1,style2"}">...</div> Code:
.style1 { background: #ccc; } |
Re: Using foreach, how do you alternate product list Div's background color
Thanks, PhilJ... That's so much simpler than IF and ELSE statements... for future reference can you tell me how the cycle code works... or provide a link to resource... is that built into PHP, SMARTY, etc.?
|
Re: Using foreach, how do you alternate product list Div's background color
|
Re: Using foreach, how do you alternate product list Div's background color
awesome... thanks
|
All times are GMT -8. The time now is 03:44 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.