[Interchange-bugs] [Bug 184] Changed - Error setting cart inside a loop
bugzilla-daemon@developer.akopia.com
bugzilla-daemon@developer.akopia.com
Fri, 11 May 2001 11:55:35 -0400
http://developer.akopia.com/bugs/show_bug.cgi?id=184
*** shadow/184 Thu May 10 18:29:40 2001
--- shadow/184.tmp.17011 Fri May 11 11:55:35 2001
***************
*** 45,47 ****
--- 45,85 ----
thanks
)\(elson
+
+ ------- Additional Comments From nferrari@ccsc.com 2001-05-11 11:55 -------
+ What seems to be happening is that whatever is inside the [loop
+ interpolate=1][/loop] is processed only once (except for the [loop]-related
+ tags) and repeated as many times as needed.
+
+ This way, the following code:
+
+ ===================
+
+ [set my_stores_bought_from]store1 store2[/set]
+ [perl]
+ my( @stores ) = split " ", $Scratch->{my_stores_bought_from};
+ sub my_next_store { return shift @stores };
+ sub my_reset_stores { @stores = split " ", $Scratch->{my_stores_bought_from};
+ return; };
+ return join " ", "current stores:", @stores, "<br>";
+ [/perl]
+ [loop interpolate=1 prefix=store arg="[scratch my_stores_bought_from]"]
+ [store-code]: [perl]my_next_store();[/perl]<br>
+ [/loop]
+ [perl]my_reset_stores();[/perl]
+ [loop prefix=store arg="store1 store2"]
+ [store-code]: [perl]my_next_store();[/perl]<br>
+ [/loop]
+
+ ===================
+
+ will generate:
+
+ current stores: store1 store2
+ store1: store1
+ store2: store1
+ store1: store1
+ store2: store2
+
+ Notice that when "interpolate=1" is used, my_next_store() is called only once.
+ When it is not used, it is called twice.