Include Products on Cat Page Based on PRODUCT.Field value

Questions and answers about ShopSite Custom Templates

Include Products on Cat Page Based on PRODUCT.Field value

Postby GiftSpecialists » Thu Aug 25, 2011 5:52 pm

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
Rick,

www.GiftSpecialistsInc.com
www.WineGiftClub.com - Gifts for wine lovers
www.BeerOnTheWall.com - Gifts for beer lovers
GiftSpecialists
 
Posts: 130
Joined: Thu Aug 17, 2006 7:20 am
Location: Modesto, California

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

Postby ShopSite Lauren » Fri Aug 26, 2011 10:51 am

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 --]
- ShopSite Lauren
Contact me for help with any of your
custom ShopSite template questions.
ShopSite Lauren
 
Posts: 889
Joined: Fri Aug 11, 2006 1:35 pm
Location: Orem, UT


Return to Custom Template Questions

Who is online

Users browsing this forum: No registered users and 29 guests