Adding a vertical line between products in a loop

General ShopSite user discussion

Adding a vertical line between products in a loop

Postby royhink » Wed Jul 25, 2007 3:49 pm

I'd like to add a vertical dotted line between the products in a 2 column loop.

I've put in the following code, but it puts a line on the right side of both columns. Any thoughts on how to make it just between columns? Is there a way to check if the product is an "even" numbered product, and put some kind of IF_ tag in to check?

[-- PRODUCT WTP_Product_1 --]
</td>
<!-- ## code for dividing line between products ## -->
<td valign="middle" width="2">
<img src="media/WTP/vert.gif" alt="" height="190" width="2" border="0" />
</td>

Any thoughts?

Thanks,

Roy
royhink
 
Posts: 104
Joined: Fri Jul 20, 2007 10:04 am
Location: Petaluma, CA

Postby Jim » Wed Jul 25, 2007 7:06 pm

Use a VAR to keep track if you are in the first cell of the row or the second. Use the INC parameter to increment the VAR when you get to the second column. Then check the VAR to see if it is 1 or 2 and if it is 1 then output the <img src="media/WTP/vert.gif" alt="" height="190" width="2" border="0" /> and if not don't output that.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Postby royhink » Thu Jul 26, 2007 2:52 pm

I still have the dividing line on both cells. Here is what I've done. If you see anything let me know!!

[-- LOOP PRODUCTS PAGE.Columns--]

<!-- set VAR to 1 after every row tag -->
[-- VAR.CellNum "1" --]

<td height="200" width="49%" valign="top" align="middle">
[-- PRODUCT WTP_HomeProd --]
</td>

<!-- IF VAR = "1" then put in dividing line image -->
[-- IF VAR.CellNum "1" --]
<td valign="middle" width="2%">
<img src="media/WTP/vert.gif" alt="" height="190" width="2" border="0" />
</td>
<!-- add INC to var -->
[-- VAR.CellNum INC --]
[-- END_IF --]

[-- END_LOOP PRODUCTS --]
royhink
 
Posts: 104
Joined: Fri Jul 20, 2007 10:04 am
Location: Petaluma, CA

Postby loren_d_c » Thu Jul 26, 2007 3:11 pm

Because you have [-- VAR.CellNum "1" --] inside the LOOP, it will be set to this everytime through the loop (every product), not just each time the row tags are output. Also, you need and ELSE at the end so that if your VAR is not 1, then you reset it to 1 so that the next time through the loop it would be. Also note that something like this would only work for a specific number of columns, so using PAGE.Columns instead of a hard number of columns is not safe in this instance. I would recommend more like this:


<!-- set VAR to 1 after every row tag -->
[-- VAR.CellNum "1" --]

[-- LOOP PRODUCTS 2 --]

<td height="200" width="49%" valign="top" align="middle">
[-- PRODUCT WTP_HomeProd --]
</td>

[-- IF VAR.CellNum "1" --]
<!-- IF VAR = "1" then put in dividing line image -->
<td valign="middle" width="2%">
<img src="media/WTP/vert.gif" alt="" height="190" width="2" border="0" />
</td>
<!-- add INC to var -->
[-- VAR.CellNum "2" --]
[-- ELSE --]
<!-- ELSE (VAR = "2") need to set VAR to "1" for the next round -->
[-- VAR.CellNum "1" --]
[-- END_IF --]

[-- END_LOOP PRODUCTS --]

-Loren
loren_d_c
 
Posts: 2569
Joined: Fri Aug 04, 2006 12:02 pm
Location: Anywhere

Postby royhink » Thu Jul 26, 2007 4:31 pm

That worked great.

Thanks, Loren and Jim for the help.

Roy
royhink
 
Posts: 104
Joined: Fri Jul 20, 2007 10:04 am
Location: Petaluma, CA


Return to User Forum

Who is online

Users browsing this forum: No registered users and 134 guests