Page 1 of 1

Include Products on Cat Page Based on PRODUCT.Field value

PostPosted: Thu Aug 25, 2011 5:52 pm
by GiftSpecialists
How can I code the templates so that a product only appears on a category page if a PRODUCT.Field is a certain value.

Example: I would like to simply assign ALL products, to ALL category pages, but use PRODUCT.Fields to determine if the product is added to that category page during the loop.

Something like this:

[-- IF PRODUCT.Field10 light-beer --]
then all light beers will get added to the category page
[-- END_IF --]

We have many beers that I would like to assign to many different category pages, but it is a logistics nightmare to assign each product to all the various pages it belongs on, and be sure that we get the right beers on the right pages, and keep them correct over the years.

Can this idea work?

The problem I see is that SS automatically adds a table row/ceell for every product, before it gets to the DEFINE-PRODUCT template. So if I coded it as above, I would just get an empty table cell, and then it would loop to the next product.

Thanks for any help.
Rick

Re: Include Products on Cat Page Based on PRODUCT.Field valu

PostPosted: Fri Aug 26, 2011 10:51 am
by ShopSite Lauren
You can do this by using DIVs rather than a table structure. Or by adding VAR tags, and having the product template create the cell rather than the page template. For example, in your page template you would have:

[-- VAR.Category Page.Field1 --]
[-- VAR.Count "0" --]
<table>
[-- LOOP PRODUCTS --]
[-- IF VAR.Count "0" --]<tr>[-- END_IF --]
[-- PRODUCT --]
[-- IF VAR.Count "3" --]</tr>[-- VAR.Count "0" --][-- END_IF --]
[-- END_LOOP PRODUCTS --]
</table>

Then in your product template, you would setup something similar to:

[-- IF PRODUCT.Field1 EQ VAR.Category --]
<td>
product information here
</td>
[-- END_IF --]