Setting variables in subproduct loop not working.

General ShopSite user discussion

Setting variables in subproduct loop not working.

Postby Matthew J. Drollinger » Wed Dec 07, 2005 2:23 pm

I'm having an issue where I am trying to toggle a variable value each time
it is accessed in a subproduct loop. For some reason, the variable value
resets to its initial value whenever the loop reiterates.

Here is an example of the code within the SUBPRODUCTS definition:
-------------------------------------------------------------------------
[-- VAR.SubProductIsEvenOdd odd --]

[-- LOOP SUBPRODUCTS --]

[-- IF VAR.SubProductIsEvenOdd odd --]
odd [-- VAR.SubProductIsEvenOdd even --] [--
VAR.SubProductIsEvenOdd --]
[-- ELSE --]
even [-- VAR.SubProductIsEvenOdd odd --] [--
VAR.SubProductIsEvenOdd --]
[-- END_IF --]

[-- SUBPRODUCTS --]

[-- END_LOOP SUBPRODUCTS --]
-------------------------------------------------------------------------

Here is an example of the output:
-------------------------------------------------------------------------
odd even [the subproduct is displayed]
odd even [the subproduct is displayed]
odd even [the subproduct is displayed]
-------------------------------------------------------------------------

I can see that within each iteration, the value is reset correctly, however
the reset value does not pass through to the next iteration.

What this should do (in theory) is toggle between odd and even so that it
results in:
-------------------------------------------------------------------------
odd even [the subproduct is displayed]
even odd [the subproduct is displayed]
odd even [the subproduct is displayed]
-------------------------------------------------------------------------

Any ideas why this is not working or how I can toggle a variable value
through each iteration of a subproduct?

Thank you,

Matthew
Matthew J. Drollinger
 

Re: Setting variables in subproduct loop not working.

Postby jim » Wed Dec 07, 2005 10:14 pm

I have used code similar to this a number of times and it has worked
just fine.

Does the product you are testing on have 3 subproducts or are there 3
products each with one subproduct? Does the VAR.SubProductIsEvenOdd get
modified in the subproduct section of the template?

Jim

Matthew J. Drollinger wrote:
I'm having an issue where I am trying to toggle a variable value each time
it is accessed in a subproduct loop. For some reason, the variable value
resets to its initial value whenever the loop reiterates.

Here is an example of the code within the SUBPRODUCTS definition:
-------------------------------------------------------------------------
[-- VAR.SubProductIsEvenOdd odd --]

[-- LOOP SUBPRODUCTS --]

[-- IF VAR.SubProductIsEvenOdd odd --]
odd [-- VAR.SubProductIsEvenOdd even --] [--
VAR.SubProductIsEvenOdd --]
[-- ELSE --]
even [-- VAR.SubProductIsEvenOdd odd --] [--
VAR.SubProductIsEvenOdd --]
[-- END_IF --]

[-- SUBPRODUCTS --]

[-- END_LOOP SUBPRODUCTS --]
-------------------------------------------------------------------------

Here is an example of the output:
-------------------------------------------------------------------------
odd even [the subproduct is displayed]
odd even [the subproduct is displayed]
odd even [the subproduct is displayed]
-------------------------------------------------------------------------

I can see that within each iteration, the value is reset correctly, however
the reset value does not pass through to the next iteration.

What this should do (in theory) is toggle between odd and even so that it
results in:
-------------------------------------------------------------------------
odd even [the subproduct is displayed]
even odd [the subproduct is displayed]
odd even [the subproduct is displayed]
-------------------------------------------------------------------------

Any ideas why this is not working or how I can toggle a variable value
through each iteration of a subproduct?

Thank you,

Matthew

jim
 

Re: Setting variables in subproduct loop not working.

Postby Matthew J. Drollinger » Fri Dec 09, 2005 6:44 pm

Thank you for your response, Jim.

I found a solution, though I still think it should have worked.

First, I shortened the length of the variable (changed it to SPIsEvenOdd).
That caused the variable resetting to work. I guess ShopSite only handles
variable names of certain length.

Then I noticed another odd problem, which was fixed by having only one [--
SUBPRODUCTS --] in the subproduct loop. Before I was using two, with one of
the two occurring when the value was "odd" and the other occurring when the
value was "even". I broke up the algorithm some more so I only needed to
use one [-- SUBPRODUCTS --] . Oddly, having them not broken up worked when
I looped through products... just not when I looped through subproducts.

I'm glad to have figured this out. This was my first ShopSite site, so this
is just another issue I probably won't run into again, or I'll know what to
do if it does happen.

Thanks again,

Matt

-----------------------------------------------------------------------------------------------------


"jim" <jstavast@xmission.com> wrote in message
news:dn8bv2$ncn$1@eval.shopsite.com...
I have used code similar to this a number of times and it has worked just
fine.

Does the product you are testing on have 3 subproducts or are there 3
products each with one subproduct? Does the VAR.SubProductIsEvenOdd get
modified in the subproduct section of the template?

Jim

Matthew J. Drollinger wrote:
I'm having an issue where I am trying to toggle a variable value each
time it is accessed in a subproduct loop. For some reason, the variable
value resets to its initial value whenever the loop reiterates.

Here is an example of the code within the SUBPRODUCTS definition:
-------------------------------------------------------------------------
[-- VAR.SubProductIsEvenOdd odd --]

[-- LOOP SUBPRODUCTS --]

[-- IF VAR.SubProductIsEvenOdd odd --]
odd [-- VAR.SubProductIsEvenOdd even --] [--
VAR.SubProductIsEvenOdd --]
[-- ELSE --]
even [-- VAR.SubProductIsEvenOdd odd --] [--
VAR.SubProductIsEvenOdd --]
[-- END_IF --]

[-- SUBPRODUCTS --]

[-- END_LOOP SUBPRODUCTS --]
-------------------------------------------------------------------------

Here is an example of the output:
-------------------------------------------------------------------------
odd even [the subproduct is displayed]
odd even [the subproduct is displayed]
odd even [the subproduct is displayed]
-------------------------------------------------------------------------

I can see that within each iteration, the value is reset correctly,
however the reset value does not pass through to the next iteration.

What this should do (in theory) is toggle between odd and even so that it
results in:
-------------------------------------------------------------------------
odd even [the subproduct is displayed]
even odd [the subproduct is displayed]
odd even [the subproduct is displayed]
-------------------------------------------------------------------------

Any ideas why this is not working or how I can toggle a variable value
through each iteration of a subproduct?

Thank you,

Matthew
Matthew J. Drollinger
 


Return to User Forum

Who is online

Users browsing this forum: No registered users and 167 guests