Browse All Fiddles


View "Miva Array Difference with miva_array_filter()"
<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 (l.big_item CIN l.settings:lists:small)', l.settings:lists:difference )" /> <mvt:eval expr="glosub(miva_array_serialize(l.settings:lists), ',', '<br>')" />
 

Basket #59355

Created: 1505321387
View "Basket #59355"
&mvte:global:Screen;
 

Basket #58852

Created: 1505154402
View "Basket #58852"
<mvt:assign name="l.settings:advancemonth" value="padl(s.dyn_tm_mon, 2,0)"/> <mvt:assign name="l.settings:thisday" value="padl(s.dyn_tm_mday, 2,0)"/> <mvt:if expr ="l.settings:advancemonth EQ 1"> <mvt:assign name="l.settings:over28" value="'29,30,31'"/> <mvt:if expr ="l.settings:thisday CIN l.settings:over28"> <mvt:assign name="l.settings:thisday" value="'28'"/> </mvt:if> <mvt:else> <mvt:assign name="l.settings:over30" value="'31'"/> <mvt:if expr ="l.settings:thisday CIN l.settings:over30"> <mvt:assign name="l.settings:thisday" value="'30'"/> </mvt:if> </mvt:if> <mvt:if expr ="l.settings:advancemonth EQ 12"> <mvt:assign name="l.settings:advancemonth" value="'01'"/> <mvt:else> <mvt:assign name="l.settings:advancemonth" value="l.settings:advancemonth+1"/> </mvt:if> <mvt:assign name="g.YMDDate" value="s.dyn_tm_year$'-'$l.settings:advancemonth$'-'$l.settings:thisday"/> <mvt:comment> ###### This writes YYYY-MM-DD format one month in advance. ###### </mvt:comment> <mvt:comment> ###### IF the order was placed on January 29,30,31 it will advance the date to February the 28th. ###### </mvt:comment> <mvt:comment> ###### ELSE if the order was placed on the "31st" it will advance the date one month to the 30th. ###### </mvt:comment> &mvt:global:YMDDate;
 

Basket #58345

Created: 1504930620
View "Basket #58345"
<mvassign name="l.foo" value="HEY"></mvassign> <mveval expr="{ l.foo }"> </mveval>
 
View "Basket #48599"
<mvt:assign name="g.string" value="'cat, dog bob edward sally'" /> <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 #57957

Methods for splitting strings to arrays
Created: 1504715800
View "Basket #57957"
<mvt:assign name="g.array[1]" value=" 'apple' "/> <mvt:assign name="g.array[2]" value=" 'orange' "/> <mvt:assign name="g.array[3]" value=" 'banana' "/> &mvt:global:array; <mvt:assign name="g.randomFruit" value="g.array[ random( miva_array_max(g.array) ) ]" /> &mvte:global:randomFruit; <mvt:assign name="l.settings:number" value="random(3)" /> &mvt:number;
 

Basket #57815

Created: 1504626012
View "Basket #57815"
<mvt:assign name="g.time_zone" value="'-5'" /> <mvt:assign name="g.dailypgrp" value=" 'DailyDeal' $ time_t_dayofmonth(dyn_time_t,time_zone) " /> &mvt:global:dailypgrp;
 

Basket #57351

Created: 1504300602
View "Basket #57351"
<mvt:assign name="g.string" value=" 'Miva Merchant, Version 9 ,is the current version of Miva Merchant.' " /> <mvt:assign name="g.new_string" value="glosub(g.string, ',' , '')" /> &mvt:global:new_string;
 

Basket #57209

Simply changes any order_Status that is "Pending" to "In Progress"
Created: 1504214967
View "Basket #57209"
<mvt:assign name="l.settings:scrubme" value="'I am a really long and boring sentance.'"/> <mvt:assign name="g.return_value" value="substring( l.settings:scrubme, 0, 10 )" /> &mvt:global:return_value;
 

Basket #56990

Created: 1504048136
View "Basket #56990"
<mvt:comment> <!-- Welcome to Miva <snippets/> You can enter standalone blocks of Miva template code then Run or Save your code to see the result. Try inserting a snippet by clicking an Insert from the left or select the Learn/Browse menu items to see some examples --> </mvt:comment>
 
View "Basket #56916"
<mvt:assign name="g.saProdCategories[1]" value="'Gear Set'" /> <mvt:assign name="g.saProdCategories[2]" value="'Jerseys'" /> <mvt:assign name="g.saProdCategories[3]" value="'Pants'" /> <mvt:assign name="g.saProdCategories[4]" value="'Gloves'" /> <mvt:assign name="g.saProdCategories[5]" value="'Guards & Braces'" /> <mvt:assign name="g.saProdCategories[6]" value="'Chest Protectors'" /> <mvt:assign name="g.saProdCategories[7]" value="'Base Layers'" /> <mvt:assign name="g.saProdCategories[8]" value="'Casual Shirts'" /> <mvt:assign name="g.saProdCategories[9]" value="'Casual Pants'" /> <mvt:assign name="g.saProdCategories[10]" value="'Hats'" /> <mvt:assign name="g.saProdCategories[11]" value="'Socks'" /> <mvt:assign name="g.saProdCategories[12]" value="'Shoes'" /> <mvt:assign name="g.saProdCategories[13]" value="'Boots'" /> <mvt:assign name="g.saProdCategories[14]" value="'Goggles'" /> <mvt:assign name="g.pCat" value="'Boots'" /> Category : &mvt:global:pCat;<br/> POS: <mvt:eval expr="miva_array_search( g.saProdCategories, 1, l.saCategory, 'l.saCategory EQ \'' $ g.pCat $ '\'' )" /> <mvt:eval expr="l.attribute"/>
 
View "Snippet: 1503688457 - v2"
<h2>Static</h2> <mvt:do file="g.Module_Library_DB" name="l.success" value="Product_Load_ID( '1', l.settings:product )" /> <mvt:eval expr="l.settings:product:code" /> <br> ==================================================== <br> <h2>Dynamic</h2> <mvt:assign name="g.fn" value="'Product_Load_ID'" /> <mvt:do file="g.Module_Library_DB" name="l.success" value="g.fn('1', l.settings:test)" /> <mvt:eval expr="l.settings:test:code" />
 

Basket #56665

 math
Created: 1503680577
View "Basket #56665"
<mvt:assign name="l.settings:roundme" value="8.95" /> <mvt:eval expr="l.settings:roundme ROUND 0" /><br/> <mvt:do name="l.result" file="g.Module_Root $ g.Store:currncy_mod:module" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, 1.25 )" />
 
View "Basket #56616"
<mvt:assign name="l.settings:attributes[1]:siteId" value="''" /> <mvt:assign name="siteId" value="'123'" /> <mvt:assign name="l.settings:attributes[2]:templateId" value="'12333'" /> <mvt:assign name="l.settings:attributes[3]:currentPageUrl" value="'0'" /> <mvt:assign name="l.settings:saParameter" value="l.settings:attributes" /> <mvt:assign name="g.var" value="'foo'" /> <mvt:do file="g.Module_JSON" name="l.success" value="JSON_Encode(l.settings:saParameter)" /> <mvt:eval expr="success"/>
 
View "Basket #56548"
<mvt:assign name="l.parameter[1]" value="'{\"config\":{\"siteId\": \"7850070\",\"templateId\": \"221\",\"currentPageUrl\": \"0\"},\"productId\":\"\'&mvt:product:Code\'\"}'" /> <mvt:eval expr="l.parameter"/>
 
View "Basket #55998"
<mvt:call action="'//s28.socialannex.com/v2.0/review/getReviews'" method="'POST'" fields="'parameter={\"config\":{\"siteId\": \"7850070\",\"templateId\": \"221\",\"currentPageUrl\": \"0\"},\"productId\":\"122\"}'"> <mvt:eval expr="s.callvalue" /> </mvt:call>
 

Basket #55979

capitalize a string
Created: 1503004065
View "Basket #55979"
<h2>MivaScript MOD</h2> <p>MivaScript has a built in Modulus opperator: <code>MOD</code></p> <mvt:assign name="l.settings:total_ports" value="112" /> <mvt:assign name="l.settings:total_blocks" value="floor((l.settings:total_ports -1) / 24) +1" /> <code>total blocks:</code>&mvt:total_blocks;<br></br> <mvt:if expr="l.settings:total_ports GE 112"> <code>wait! please call us</code> </mvt:if>
 

Basket #55902

Created: 1502919755
View "Basket #55902"
<MvFUNCTION NAME = "Replace" PARAMETERS = "string, search, replace, start VAR" STANDARDOUTPUTLEVEL = ""> <MvCOMMENT> <MvASSIGN NAME="g.string" VALUE="{ 'Now is the time for all good men to come to the aid of their nation.' }"> <MvEVAL EXPR="{ Replace(g.string, 'nation', 'country', g.start) }"><br> <MvEVAL EXPR="{ g.start }"> </MvCOMMENT> <MvASSIGN NAME = "l.savestring" VALUE = "{ l.string }"> <MvIF EXPR = "{ l.start LT 1 }"> <MvASSIGN NAME = "l.start" VALUE = "{ 1 }"> </MvIF> <MvIF EXPR = "{ l.start GT 1 }"> <MvASSIGN NAME = "l.left" VALUE = "{ substring(l.string,1,l.start -1) }"> </MvIF> <MvASSIGN NAME = "l.string" VALUE = "{ substring(l.string,l.start,len(l.string)) }"> <MvASSIGN NAME = "l.posn" VALUE = "{ l.search IN l.string }"> <MvIF EXPR = "{ l.posn GT 1 }"> <MvASSIGN NAME = "l.left" VALUE = "{ l.left $ substring(l.string,1,(l.posn -1)) }"> <MvASSIGN NAME = "l.string" VALUE = "{ substring(l.string,l.posn,len(l.string)) }"> </MvIF> <MvIF EXPR = "{ (l.search IN l.string ) EQ 1 }"> <MvASSIGN NAME = "l.right" VALUE = "{ substring(l.string,len(l.search)+1,len(l.string)) }"> <MvASSIGN NAME = "l.start" VALUE = "{ len(l.left $ l.replace) + 1 }"> <MvASSIGN NAME = "l.return" VALUE = "{ l.left $ l.replace $ l.right }"> <MvIF EXPR = "{ l.start GT len(l.return) }"> <MvASSIGN NAME = "l.start" VALUE = "{ 0 }"> </MvIF> <MvELSE> <MvASSIGN NAME = "l.return" VALUE = "{ l.savestring }"> <MvASSIGN NAME = "l.start" VALUE = "{ 0 }"> </MvIF> <MvFUNCRETURN VALUE = "{ l.return }"> </MvFUNCTION>
 

Basket #51757

Created: 1502233163
View "Basket #51757"
<mvt:assign name="l.settings:list[1]:name" value="'1apples'" /> <mvt:assign name="l.settings:list[1]:val" value="'v1'" /> <mvt:assign name="l.settings:list[2]:name" value="'2bananas'" /> <mvt:assign name="l.settings:list[2]:val" value="'v2'" /> <mvt:assign name="l.settings:list[3]:name" value="'3carrots'" /> <mvt:assign name="l.settings:list[3]:val" value="'v3'" /> <h2>Before</h2> <mvt:foreach iterator="item" array="list"> &mvt:item:name; + &mvt:item:val;<br> </mvt:foreach> <mvt:do file="g.module_library_utilities" name="l.null" value="QuickSortArray(l.settings:list, ':name', 1)" /> <h2>After</h2> <mvt:foreach iterator="item" array="list"> &mvt:item:name;<br> </mvt:foreach>
 
View "Get Everything after a String"
<mvt:assign name="g.string" value="'something.com/goes-here.html'" /> <mvt:assign name="g.split" value="'.com'" /> <mvt:assign name="g.after_index" value="(g.split CIN g.string) + len(g.split)" /> <mvt:assign name="g.after" value="substring( g.string, g.after_index , len(g.string) )" /> &mvte:global:after;
 

Using MVT inside JavaScript

The MVT populates first before the JavaScript runs.
Created: 1501245342
View "Using MVT inside JavaScript"
<!-- Assign our two values --> <mvt:assign name="g.valueOne" value="1" /> <mvt:assign name="g.valueTwo" value="2" /> <!-- We can use mvt with JavaScript because the values are inserted before JavaScript executes --> <script> var test = &mvt:global:valueOne; + &mvt:global:valueTwo;; document.write(test); </script>
 

Basket #52503

Methods for splitting strings to arrays
Created: 1501196880
View "Basket #52503"
<mvt:assign name="g.string" value="'asdfasdf'" /> <h3>Split String mvt:do</h3> <p>Does not inherently support multi-character splitting, you'd have to perform a glosub first (see next example)</p> <mvt:do file="g.Module_Library_Utilities" name="l.success" value="SplitString( g.string, '|', g.splitString )" /> <!-- @@ &mvt:global:MvDO_Error; --> <mvt:assign name="g.relprod_arr_len" value="miva_array_elements(g.splitString )" /> Cookie recentproductd array length: &mvt:global:relprod_arr_len; <br> <mvt:foreach iterator="line" array="global:splitString"> &mvt:line;</br> </mvt:foreach> <br> <h3>Deserialize+Global Substitution</h3> <p>This method supports multi-character splitting, as you're just replacing your seperator with a single comma</p> <mvt:assign name="g.array" value="miva_array_deserialize( glosub(g.string,'|',',') )" /> <mvt:foreach iterator="line" array="global:array"> &mvt:line;</br> </mvt:foreach>
 

Basket #52340

Created: 1501171214
View "Basket #52340"
<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 #52331

Created: 1501002842
View "Basket #52331"
<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, '', 0)" /> <h2>After</h2> <mvt:foreach iterator="item" array="list"> &mvt:item;<br> </mvt:foreach>
 

Basket #52185

Created: 1500917824
View "Basket #52185"
&mvt:url;