Originally posted by Scot - ScotsScripts.com
View Post
Announcement
Collapse
No announcement yet.
array_insert issue
Collapse
X
-
Thanks! That seems to have cleared it up and doing more testing on it now.Originally posted by Scot - ScotsScripts.com View PostLook at the mvforeach. I put l.disco and l.discos and you had disco and discos
Leave a comment:
-
My quick test using your original code output the values as expected. I'd double check what's actually being returned from your custom field call.
outputCode:<MvASSIGN NAME = "l.discos" VALUE = "{ miva_array_deserialize( '[1]=A,[2]=B,[3]=C' ) }" /> <MvFOREACH ITERATOR = "disco" ARRAY = "discos"> <MvASSIGN NAME = "l.ok" VALUE = "{ miva_array_insert( l.disco_list, l.disco, -1 ) }" /> </MvFOREACH> <MvEVAL EXPR = "{ l.disco_list }">
Code:A,B,C
Leave a comment:
-
Look at the mvforeach. I put l.disco and l.discos and you had disco and discos
Leave a comment:
-
Ok, I just noticed you're not scoping your variables. When using miva script you have to scope variables, it's not like mvt code. Try this:
Code:<MvFOREACH ITERATOR = "l.disco" ARRAY = "l.discos"> <MvASSIGN NAME = "l.ok" VALUE = "{ miva_array_insert( l.disco_list, l.disco, -1 ) }" /> </MvFOREACH>
Leave a comment:
-
array_elements does produce the correct number.
I tried the direct assign and that produces the same result missing the first value.
Leave a comment:
-
First thing I would try is to make sure l.discos has three array elements by evaluating miva_array_elements(l.discos)
Also, you may want to consider simply assign l.disco_list the l.discos array instead of going around with the miva_Array_insert...
Code:<MvASSIGN NAME = "l.disco_list" VALUE = "{ l.discos }" />
Leave a comment:
-
array_insert issue
I am running into something that I can't really figure out or even explain. A very simplified version of the code and the result is below, it is dropping the first result for some reason.
Custom Field = A,B,CCode:<MvASSIGN NAME = "l.discos" VALUE = "{ miva_array_deserialize( Module_Product_Field_Value( l.module, Items.d.product_id, 'raves' ) ) }" /> <MvFOREACH ITERATOR = "disco" ARRAY = "discos"> <MvASSIGN NAME = "l.ok" VALUE = "{ miva_array_insert( l.disco_list, l.disco, -1 ) }" /> </MvFOREACH>
l.discos = A,B,C
l.disco_list = B,CTags: None
Leave a comment: