Page 1 of 1
Extra Fields as Flags?
Posted:
Sun Feb 27, 2011 6:12 pm
by Yachtsman
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 --]
Re: Extra Fields as Flags?
Posted:
Sun Feb 27, 2011 6:58 pm
by Jim
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.
Re: Extra Fields as Flags?
Posted:
Sat Mar 05, 2011 5:22 am
by mjbrunelle
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 --]