PDA

View Full Version : Every other product in <mvt:foreach>


1st Ergo
03-29-06, 04:26 AM
Hello all,

I am using this code on my category page.

<mvt:foreach iterator="product" array="products">
<tr>
<td align="left" valign="center" colspan=2>
<mvt:item name="fonts" param="ctgy_font">
<a href="/p/&mvta:product:code;">&mvt:product:code;
</a>
</mvt:item>
</td>
</tr>

I want to display a background color on Every Other Row.

I'm thinking something like this: If product number = odd then bgcolor=

How would I do this?

Thank you.
David

wcw
03-29-06, 01:17 PM
Normally that is stored with the variable as the array is created. However, you should also be able to check the value of pos1 If it is odd (use MOD operator) make the bgcolor one thing, even make it the other.

1st Ergo
03-29-06, 07:05 PM
Hi Bill,

I really appreciate your help!

I have successfully colored every other table row. However, I think there must be a better way. Here is what I did.

<mvt:foreach iterator="product" array="products">
<tr>
<td>
<a href="/p/&mvtaroduct:code;">&mvtroduct:code;
</a>
</td>

<mvt:if expr = "(pos2 MOD 2 ) EQ 0">
</tr>

<tr bgcolor="green">
<td>
<a href="/p/&mvtaroduct:code;">&mvtroduct:code;
</a>
</td>
</tr>
</mvt:if>

Is this what you where thinking?

Thank you.
David

sebenza
03-29-06, 09:04 PM
Hi David-
I think you are using our Category Template Manager module. If it helps, each product has the variable "bgcolor" available. For example, &mvt:product:bgcolor;

1st Ergo
03-29-06, 11:27 PM
Scott,

Yes, I'm using your cat temp module. That variable is exactly what I was looking for.

Thank you!

David