Browse All Fiddles


Basket #67402

Created: 1511218429
View "Basket #67402"
<mvt:do file="g.Module_Library_DB" name="l.settings:product:variant_count" value="ProductVariantList_Load_Product(l.settings:product:id, l.settings:product:variants)" />
 

Basket #69199

Created: 1511210701
View "Basket #69199"
<mvt:assign name="l.settings:current_hour" value="s.dyn_tm_hour" /> <mvt:assign name="l.settings:current_min" value="s.dyn_tm_min" /> <mvt:assign name="l.settings:current_month" value="s.dyn_tm_mon" /> <mvt:assign name="l.settings:current_year" value="s.dyn_tm_year" /> &mvt:current_hour;<br> &mvt:current_min;<br> &mvt:current_month;<br> &mvt:current_year;
 

Basket #68875

capitalize a string
Created: 1510761276
View "Basket #68875"
<mvt:assign name="g.str" value="'caleb was a dog'" /> <mvt:assign name="g.capitalize" value="toupper(substring(g.str,0,1)) $ subString(g.str,2,len(g.str))" /> &mvt:global:capitalize;
 

Basket #68747

capitalize a string
Created: 1510572513
View "Basket #68747"
<mvt:assign name="g.string" value="'asx asxaxs asas'" /> <mvt:do file="g.Module_Library_Utilities" name="l.null" value="SplitString( g.string, ' ', g.array )" /> &mvt:global:array;
 

Basket #68419

Created: 1510073364
View "Basket #68419"
<mvt:assign name="l.settings:list[1]" value="'apples'" /> <mvt:assign name="l.settings:list[2]" value="'bananas'" /> <mvt:assign name="l.settings:list[3]" value="'carrots'" /> <h2>Before</h2> <mvt:foreach iterator="item" array="list"> &mvt:item;<br> </mvt:foreach> <mvt:do file="g.module_library_utilities" name="l.null" value="QuickSortArray(l.settings:list, '', -1)" /> <h2>After</h2> <mvt:foreach iterator="item" array="list"> &mvt:item;<br> </mvt:foreach>
 

Basket #67794

Created: 1509668817
View "Basket #67794"
<mvt:assign name="g.string" value=" 'http://dev2.islandrose.net/flowers-philippines/irCHObrmi.html' " /> <mvt:do file="g.Module_Library_Utilities" name="l.success" value="SplitString( g.string, '/', g.splitString )" /> <mvt:foreach iterator="line" array="global:splitString"> &mvt:line;</br> </mvt:foreach> <mvt:assign name="l.settings:producturi" value="g.splitString[5]" /> &mvt:producturi; <mvt:assign name="g.flag" value="'Best Seller'" /> <mvt:assign name="g.slugified-flag" value="tolower(slugify( g.flag ))" /> &mvt:global:slugified-flag;
 

Basket #61648

Created: 1509662199
View "Basket #61648"
<mvt:assign name="l.index" value="miva_array_insert( l.settings:arr, 'Foo', -1 )" /> <mvt:assign name="l.index" value="miva_array_insert( l.settings:arr, 'bar', -1 )" /> <mvt:foreach iterator="a" array="arr"> &mvt:a; </mvt:foreach>
 
View "Basket #62659"
<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:assign name="g.string_again" value="glosub( g.array, ',', '|' )" /> &mvt:global:array;<br> &mvte:global:string_again;<br>
 

Basket #67622

This code will allow you to show/hide banners or other layout changes based on if a price group is active or not.
Created: 1509472575
View "Basket #67622"
<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:attributes[2]:prompt" value="'Select a Color:'" /> <mvt:assign name="l.settings:attributes[3]:template_code" value="'foo'" /> <mvt:assign name="l.settings:attributes[3]:prompt" value="'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.holdvalue, 'l.holdvalue:template_code EQ \'' $ g.var $ '\'' )" /> <mvt:eval expr="l.holdvalue"/>
 

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/>