Extra Fields as Flags?

Questions and answers about ShopSite Custom Templates

Extra Fields as Flags?

Postby Yachtsman » Sun Feb 27, 2011 6:12 pm

Can I use an extra field in a product record to use as a flag during execution?

Something like:
[-- IF PRODUCT.Field1? --]
do something
[-- END IF --]
Yachtsman
 
Posts: 24
Joined: Fri Dec 11, 2009 9:21 am
Location: washington

Re: Extra Fields as Flags?

Postby Jim » Sun Feb 27, 2011 6:58 pm

See the main help for the IF tag on:
http://shopsite.com/help/10.2/en-US/sc/pro/custom.template.spec-global.html

Basically there are 2 formats.

[-- IF parameter --] Tests if a parameter is checked or not empty (True), and processes the following code if True.
[-- IF parameter1 parameter2 --] Tests if parameter1 is equal to parameter2 (True), and processes the following code if True.

You would use the second type since the first would always be True if there were anything in the field. You probably want to execute the code for specific values in the field not just if there is any thing in the field. So the format to use will be

[-- IF PRODUCT.Field1 "compare value" --]
do something
[-- END IF --]

You can also use the [-- ELSE_IF param3 {param4} --] if the field contains different values and you want to do something special for several cases.
[-- IF PRODUCT.Field1 "Book" --]
do layout for Book
[-- ELSE_IF PRODUCT.Field1 "DVD" --]
do layout for DVD
[-- ELSE_IF PRODUCT.Field1 "MP3" --]
do layout for MP3
[-- ELSE --]
do normal layout
[-- END IF --]

You need to use the quotes around the value you are comparing to in case there are multiple words.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Extra Fields as Flags?

Postby mjbrunelle » Sat Mar 05, 2011 5:22 am

Here are examples, we have different product table column counts depending on the product group being viewed.

We use Product.Field10 through 14 for the product data, and Page.Field10 through 14 for the column headers.

In the product template,

[-- IF PRODUCT.Field10 --]
<td class="productRow">[-- PRODUCT.Field10 --]</td>
[-- END_IF --]
[-- IF PRODUCT.Field11 --]
<td class="productRow">[-- PRODUCT.Field11 --]</td>
[-- END_IF --]
and so on

There is a corresponding sequence in the page template to included the add columns headers.

As for the other method Jim pointed out, we have multiple page types. Based on the page field data we include a different page definition.

<td class="contentpage">
[-- IF PAGE.Field2 "NoProduct" --]
[-- INCLUDE dmiNoProductPage.sst PROCESS --]
[-- ELSE_IF PAGE.Field2 "Product" --]
[-- INCLUDE dmiProductPage.sst PROCESS --]
[-- ELSE_IF PAGE.Field2 "Catalog" --]
[-- INCLUDE dmiCatalogPage.sst PROCESS --]
[-- ELSE_IF PAGE.Field2 "Category" --]
[-- PAGE.Text2 --]

and so on. to [-- END_IF --]
mjbrunelle
 
Posts: 147
Joined: Sun Jun 21, 2009 5:09 am


Return to Custom Template Questions

Who is online

Users browsing this forum: No registered users and 99 guests