Browse All Fiddles


Basket #57816

Methods for splitting strings to arrays
Created: 1508960120
View "Basket #57816"
<mvt:assign name="g.foo" value="substring( 'flavor:chock' , 8 , 10)" /> &mvte:global:foo;
 

Basket #67233

 date  math
Get the formatted date one week from now.
Created: 1508948888
View "Basket #67233"
<mvt:assign name="g.current_time" value="s.dyn_time_t" /> <mvt:comment><!-- <mvt:assign name="g.timezone_offset" value="'-4'" /> --></mvt:comment> <mvt:assign name="g.timezone_offset" value="'local'" /> <mvt:assign name="g.duration" value="60 * 60 * 24 * 395" /> <mvt:assign name="g.one_month" value="60 * 60 * 24 * 30" /> <mvt:assign name="g.future_time" value="g.current_time + g.duration"/> <mvt:assign name="g.year" value="time_t_year( g.future_time, g.timezone_offset )" /> <mvt:assign name="g.month" value="padl(time_t_month( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.day" value="padl(time_t_dayofmonth( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.24hour" value="padl(time_t_hour( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.min" value="padl(time_t_min( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.sec" value="padl(time_t_sec( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.formatted_future_date" value="g.year $ '-' $ g.month $ '-' $ g.day $ ' ' $ g.24hour $ ':' $ g.min $ ':' $ g.sec" /> <mvt:assign name="g.time_teste" value="g.future_time - g.current_time"/> <mvt:assign name="g.teste_month" value="floor(g.time_teste/g.one_month)" /> &mvt:global:formatted_future_date; <br> &mvt:global:teste_month;
 
View "Basket #67206"
<mvt:assign name="l.settings:attributes[1]:template_code" value="'size'" /> <mvt:assign name="l.settings:attributes[1]:prompt" value="'Select a Size:'" /> <mvt:assign name="l.settings:attributes[2]:template_code" value="'color'" /> <mvt:assign name="l.settings:<mvt:assign name="g.foo" value="'bar'" /> <mvt:assign name="l.settings:attributes[3]:template_code" value="'foo'" /> <mvt:assign name="l.settings:attributes[3]:prompt" value="'Foo Bar:'" /> <mvt:assign name="l.settings:attributes[4]:template_code" value="'baz'" /> <mvt:assign name="l.settings:attributes[4]:prompt" value="'Baz!:'" /> <mvt:assign name="g.var" value="'foo'" /> POS: <mvt:eval expr="miva_array_search( l.settings:attributes, 1, l.attribute, 'l.attribute:template_code EQ \'' $ g.var $ '\'' )" /> <mvt:eval expr="l.attribute"/>
 

Basket #66544

Created: 1508345141
View "Basket #66544"
<mvt:assign name="g.current_time" value="s.dyn_time_t" /> <mvt:assign name="g.timezone_offset" value="'-5'" /> <mvt:assign name="g.weeklypgrp" value="'deal' $((time_t_dayofyear(dyn_time_t,time_zone)-time_t_dayofweek(dyn_time_t,time_zone)+10)/7) MOD 4" /> &mvt:global:weeklypgrp;<br />
 

Basket #66538

 date  math
Get the formatted date one week from now.
Created: 1508338358
View "Basket #66538"
<mvt:assign name="g.current_time" value="s.dyn_time_t" /> <mvt:comment><!-- <mvt:assign name="g.timezone_offset" value="'-4'" /> --></mvt:comment> <mvt:assign name="g.timezone_offset" value="'local'" /> <mvt:assign name="g.duration" value="60 * 60 * 24 * 7" /> <mvt:assign name="g.future_time" value="g.current_time + g.duration"/> <mvt:assign name="g.year" value="time_t_year( g.future_time, g.timezone_offset )" /> <mvt:assign name="g.month" value="padl(time_t_month( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.day" value="padl(time_t_dayofmonth( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.24hour" value="padl(time_t_hour( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.min" value="padl(time_t_min( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.sec" value="padl(time_t_sec( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.formatted_future_date" value="g.year $ '-' $ g.month $ '-' $ g.day $ ' ' $ g.24hour $ ':' $ g.min $ ':' $ g.sec" /> &mvt:global:formatted_future_date;
 

Basket #66501

Created: 1508286272
View "Basket #66501"
<mvt:assign name="g.test" value="'test&quot;ing'" /> &mvt:global:test;
 

Basket #64377

Created: 1507836538
View "Basket #64377"
<mvt:assign name="g.catcode" value="'Brand_typea'" /> <mvt:if expr="'_typea' CIN g.catcode"> <mvt:assign name="g.cat2code" value="gettoken( g.catcode, '_' , 1 )$ '_typeb'" /> </mvt:if> &mvte:global:cat2code;
 
View "Snippet: 1507782357 - v2"
<mvt:assign name="l.formatted_daysofweek[1]" value="'Sun'" /> <mvt:assign name="l.formatted_daysofweek[2]" value="'Mon'" /> <mvt:assign name="l.formatted_daysofweek[3]" value="'Tue'" /> <mvt:assign name="l.formatted_daysofweek[4]" value="'Wed'" /> <mvt:assign name="l.formatted_daysofweek[5]" value="'Thu'" /> <mvt:assign name="l.formatted_daysofweek[6]" value="'Fri'" /> <mvt:assign name="l.formatted_daysofweek[7]" value="'Sat'" /> <mvt:assign name="l.formatted_months[1]" value="'Jan'" /> <mvt:assign name="l.formatted_months[2]" value="'Feb'" /> <mvt:assign name="l.formatted_months[3]" value="'Mar'" /> <mvt:assign name="l.formatted_months[4]" value="'Apr'" /> <mvt:assign name="l.formatted_months[5]" value="'May'" /> <mvt:assign name="l.formatted_months[6]" value="'Jun'" /> <mvt:assign name="l.formatted_months[7]" value="'Jul'" /> <mvt:assign name="l.formatted_months[8]" value="'Aug'" /> <mvt:assign name="l.formatted_months[9]" value="'Sep'" /> <mvt:assign name="l.formatted_months[10]" value="'Oct'" /> <mvt:assign name="l.formatted_months[11]" value="'Nov'" /> <mvt:assign name="l.formatted_months[12]" value="'Dec'" /> <mvt:assign name="g.current_time" value="s.dyn_time_t" /> <mvt:assign name="g.timezone_offset" value="'-4'" /> <mvt:assign name="g.duration" value="60 * 60 * 24 * 1" /> <mvt:assign name="g.future_time" value="g.current_time + g.duration"/> <mvt:assign name="g.year" value="time_t_year( g.future_time, g.timezone_offset )" /> <mvt:assign name="g.month" value="padl(time_t_month( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.formatted_month" value="l.formatted_months[g.month]" /> <mvt:assign name="g.day" value="padl(time_t_dayofmonth( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.dayofweek" value="time_t_dayofweek( g.future_time, g.timezone_offset )" /> <mvt:assign name="g.formatted_dayofweek" value="l.formatted_daysofweek[g.dayofweek]" /> <mvt:assign name="g.24hour" value="padl(time_t_hour( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.min" value="padl(time_t_min( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:assign name="g.sec" value="padl(time_t_sec( g.future_time, g.timezone_offset ), 2, 0)" /> <mvt:comment><mvt:assign name="g.cookie:expiration" value="g.formatted_dayofweek $ ', ' $ g.formatted_month $ ' ' $ g.year $ ' ' $ g.24hour $ ':' $ g.min $ ':' $ g.sec $ ' GMT'" /></mvt:comment> <mvt:assign name="g.cookie:expiration" value="g.formatted_dayofweek $ ', ' $ g.day $ '-' $ g.formatted_month $ '-' $ g.year $ ' ' $ g.24hour $ ':' $ g.min $ ':' $ g.sec $ ' GMT'" /> <mvt:assign name="g.cookie:name" value="'mm5-test-cookie'" /> <mvt:assign name="g.cookie:value" value="'Eat more cookies!'" /> <mvt:assign name="g.cookie:header" value="g.cookie:name $ '=' $ g.cookie:value $ '; expires=' $ g.cookie:expiration $ '; path=/;'"/> Result: &mvte:global:output_header;<br> Debug:<br> <mvt:eval expr="decodeattribute(glosub(miva_array_serialize(g.cookie), ',', '<br>'))" />
 
View "Basket #64328"
<mvt:assign name="g.string" value="'1|2|3|4|5'" /> <mvt:assign name="g.delimiter" value="'|'" /> <mvt:do file="g.Module_Library_Utilities" name="l.null" value="SplitString( g.string, g.delimiter, g.array )" /> &mvte:global:array[1];<br> &mvte:global:array[2];<br> &mvte:global:array[3];<br> &mvte:global:array[4];<br> &mvte:global:array[5];<br> <hr/> <mvt:foreach iterator="i" array="array"> &mvt:i; </mvt:foreach> <hr /> <mvt:assign name="g.string_again" value="glosub( g.array, ',', '|' )" /> &mvt:global:array;<br> &mvte:global:string_again;<br>
 

Basket #64297

Created: 1507736277
View "Basket #64297"
<mvt:assign name="l.settings:ordersum" value="13.91"/> &mvt:ordersum; <script> function GetRevenueValue() { var ordersum = &mvt:ordersum; alert(ordersum); } GetRevenueValue() </script>
 

Basket #63416

Created: 1507675613
View "Basket #63416"
<mvt:eval expr="2 + 2" />
 

Basket #63073

Created: 1507244041
View "Basket #63073"
<mvt:assign name="l.settings:rand" value="miva_array_deserialize( '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16' )" /> <mvt:assign name="l.settings:randomme" value="l.settings:rand" /> <mvt:foreach iterator="item" array="randomme"> <mvt:assign name="g.tempRand" value="random(miva_array_elements(l.settings:randomme)-1)+1" /> <mvt:assign name="g.tempVal" value="l.settings:item" /> <mvt:assign name="l.settings:item" value="l.settings:randomme[g.tempRand]" /> <mvt:assign name="g.tempCounter" value="1" /> <mvt:foreach iterator="subItem" array="randomme"> <mvt:if expr="g.tempCounter EQ g.tempRand"> <mvt:assign name="l.settings:subItem" value="g.tempVal" /> <mvt:foreachstop /> </mvt:if> <mvt:assign name="g.tempCounter" value="g.tempCounter+1" /> </mvt:foreach> </mvt:foreach> <mvt:foreach iterator="item" array="randomme"> &mvt:item;, </mvt:foreach>
 

Basket #62720

Created: 1507044617
View "Basket #62720"
<mvt:assign name="l.settings:lists:small" value="miva_array_deserialize('Apples,Bananas,Carrots')" /> <mvt:assign name="l.settings:lists:big" value="miva_array_deserialize('Apples,Bananas,Carrots,Lemons,Limes,Oranges')" /> <mvt:assign name="l.result" value="miva_array_filter( l.settings:lists:big, 0, l.big_item, 'NOT miva_array_find( l.big_item, l.settings:lists:small, 0 )', l.settings:lists:difference )" /> <mvt:eval expr="glosub(miva_array_serialize(l.settings:lists), ',', '<br>')" />
 

Basket #60609

Created: 1506805517
View "Basket #60609"
<mvt:assign name="l.settings:array" value="miva_array_deserialize( '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16' )" /> <mvt:foreach iterator="item" array="array"> <mvt:assign name="g.tempRand" value="random(miva_array_elements(l.settings:array)-1)+1" /> <mvt:assign name="g.tempVal" value="l.settings:item" /> <mvt:assign name="l.settings:item" value="l.settings:array[g.tempRand]" /> <mvt:assign name="g.tempCounter" value="1" /> <mvt:foreach iterator="subItem" array="array"> <mvt:if expr="g.tempCounter EQ g.tempRand"> <mvt:assign name="l.settings:subItem" value="g.tempVal" /> <mvt:foreachstop /> </mvt:if> <mvt:assign name="g.tempCounter" value="g.tempCounter+1" /> </mvt:foreach> </mvt:foreach> &mvt:array;
 

Basket #62367

Executes the expression contained within value and saves that value to the variable defined in the name attribute. [Documentation](http://www.miva.com/template-language/miva_template_language/mvtassign,_mvteval.html)
Created: 1506634954
View "Basket #62367"
<mvt:assign name="g.sam" value="1 + 2" /> <mvt:assign name="g.sum" value="g.sam" /> The sum is: &mvt:global:sum;
 
View "Snippet: 1506553651 - v1"
<mvt:assign name="l.settings:scrubname" value="1 12" x 13' 3300lb Rated Black Tow Stra" /> <mvt:assign name="l.settings:scrubname" value="glosub( l.settings:scrubname, ''' , '')" /> &mvt:scrubname;
 

Basket #62289

Created: 1506548940
View "Basket #62289"
<mvt:assign name="l.settings:string" value="' Hello" my name is Bob. '" /> &mvt:string; // <mvt:assign name="l.settings:string" value="{ ReplaceChars(l.settings:string,'~`!@#$%^&*()_-+={}|[]:;<>?,./' $ asciichar(34) $ asciichar(39), ' ') }" /> &mvt:string; //
 

total ports

handles total ports required to send to JS-checkout
Created: 1506545945
View "total ports"
<h2>MivaScript MOD</h2> <p>MivaScript has a built in Modulus opperator: <code>MOD</code></p> <mvt:assign name="g.total_ports" value="72" /> <mvt:if expr="g.total_ports EQ 0"> <mvt:assign name="g.total_ports" value="1" /> </mvt:if> <mvt:assign name="g.total_ports" value="floor((g.total_ports-1) / 24)+1" /> <mvt:item name="toolkit" param="sassign|totalBlocks|g.total_ports" /> <code>3 MOD 3</code> = &mvte:global:total_ports;<br/>
 

Basket #61175

handles total ports required to send to JS-checkout
Created: 1506528842
View "Basket #61175"
<h2>MivaScript MOD</h2> <p>MivaScript has a built in Modulus opperator: <code>MOD</code></p> <mvt:assign name="g.total_ports" value="72" /> <mvt:if expr="g.total_ports EQ 0"> <mvt:assign name="g.total_ports" value="1" /> </mvt:if> <mvt:assign name="g.total_ports" value="floor((g.total_ports-1) / 24)+1" /> <mvt:item name="toolkit" param="sassign|totalBlocks|g.total_ports" /> <code>3 MOD 3</code> = &mvte:global:total_ports;<br/>
 

Basket #57070

Created: 1506362623
View "Basket #57070"
<mvt:assign name="l.test" value="2" /> &mvt:test; <mvt:assign name="l.settings:test2" value="l.test + 1" /> &mvt:settings:test2;
 

Basket #61307

Created: 1506099007
View "Basket #61307"
<mvt:assign name="g.list" value="'9.95,89.95,24.99'" /> <mvt:assign name="l.count" value="1" /> <mvt:assign name="l.token" value="gettoken(g.list, ',' , l.count)" /> <mvt:while expr="NOT ISNULL l.token"> <mvt:assign name="l.array_length" value="miva_array_insert( l.settings:my_array, l.token, -1 )" /> <mvt:assign name="l.count" value="l.count + 1" /> <mvt:assign name="l.token" value="gettoken(g.list, ',' , l.count)" /> </mvt:while> <mvt:assign name="l.settings:subtotal" value="'0'" /> <mvt:foreach iterator="array_element" array="my_array"> <mvt:assign name="l.settings:subtotal" value="l.settings:subtotal + l.settings:array_element"/> </mvt:foreach> <br/> <hr>SUBTOTAL:&mvt:subtotal;
 

Basket #61228

Created: 1506048686
View "Basket #61228"
<mvt:assign name="l.field" value="'field_field_2'" /> <mvt:assign name="l.test" value="substring_var( l.field, 7, ( len_var( l.field ) - 6 ) )" /> <mvt:eval expr="l.test" />
 
View "YYYY-MM-DD to DD/MM/YYYY"
<mvt:assign name="l.settings:event_date:yyyymmdd" value="'2017-09-19'" /> <mvt:do file="g.Module_Library_Utilities" name="l.result" value="SplitString( l.settings:event_date:yyyymmdd, '-', l.settings:event_date:parts )" /> <mvt:if expr="miva_array_elements(l.settings:event_date:parts) EQ 3 AND len(l.settings:event_date:parts[1]) EQ 4"> <mvt:assign name="l.settings:event_date:mmddyyyy" value="l.settings:event_date:parts[2] $ '/' $ l.settings:event_date:parts[3] $ '/' $ l.settings:event_date:parts[1]" /> </mvt:if> <h2>&mvt:event_date:mmddyyyy;</h2> <mvt:eval expr="glosub(miva_array_serialize(l.settings:event_date), ',', '<br>')" />
 
View "Snippet: 1505764013 - v1"
<mvt:eval expr="crypto_md5( 'hi ann' )" /><br /> <mvt:eval expr="crypto_md5( 'hi ann' )" /><br /> <mvt:eval expr="crypto_md5( 'hi ann' )" /><br />
 

Basket #53360

Created: 1505763985
View "Basket #53360"
<mvt:eval expr="0.00 EQ ''" />
 

While Loop

Created: 1505752077
View "While Loop"
<mvt:while expr="l.settings:counter LT 5"> <mvt:assign name="l.settings:counter" value="l.settings:counter + 1" /> &mvt:counter;<br> </mvt:while>