Playing around tonight and searching the forums for some help. I thought I'd put all the info in one spot about taking a comma delimited string and putting it into an array. That way, in the future, I will find this info when I'm looking for it ('cause I forget stuff all the time) and it might help someone else too.
I do have a question too. What is what is the preferred way to do this in Miva 9 and are there more ways or better ways?
I do have a question too. What is what is the preferred way to do this in Miva 9 and are there more ways or better ways?
Code:
<mvt:assign name="l.settings:wcwstuff" value="'some,foo,magic,stuff,makes,a,list,like,this'" /> <BR> Array_FromList <pre> <mvt:item name="ry_toolbelt" param="Array_FromList|l.all_settings:wcwmssgs|l.all_settings:wcwstuff" /> <mvt:foreach iterator="wcwmssg" array="wcwmssgs"> &mvt:wcwmssg; </mvt:foreach> </pre> <BR> miva_array_deserialize with toolbelt assign <pre> <mvt:item name="ry_toolbelt" param="assign|l.all_settings:wcwmssgs2|miva_array_deserialize(l.all_settings:wcwstuff)" /> <mvt:foreach iterator="wcwmssg2" array="wcwmssgs2"> &mvt:wcwmssg2; </mvt:foreach> </pre> <BR> miva_array_deserialize with mvt assign <pre> <mvt:assign name="l.settings:wcwmssgs2" value="miva_array_deserialize(l.settings:wcwstuff)" /> <mvt:foreach iterator="wcwmssg2" array="wcwmssgs2"> &mvt:wcwmssg2; </mvt:foreach> <BR> miva_splitstring <pre> <mvt:assign name="l.settings:csv" value="'star wars,hi mom!,master yoda,miva docs yay, this example is courtesy of,the,dreamingdigital,pirate'" /> <mvt:assign name="l.settings:count" value="miva_splitstring( l.settings:csv, ',', l.settings:csv_arr, '' )" /> &mvt:count; items in that csv var, yo. <mvt:foreach iterator="x" array="csv_arr"> &mvt:x; </mvt:foreach> </pre> </pre> <BR> do library utlity SplitString <pre> <mvt:assign name="l.settings:wcwmssgs2" value="miva_array_deserialize(l.settings:wcwstuff)" /> <mvt:do file="g.Module_Library_Utilities" name="l.success" value="SplitString(l.settings:wcwstuff, ',', l.settings:wcwmssgs3)" /> <mvt:foreach iterator="wcwmssg3" array="wcwmssgs3"> &mvt:wcwmssg3; </mvt:foreach> </pre>
Comment