Skip to content

Instantly share code, notes, and snippets.

@mghdotdev
Created May 14, 2015 16:23
Show Gist options
  • Save mghdotdev/48dc32e049ea22b027ae to your computer and use it in GitHub Desktop.
Save mghdotdev/48dc32e049ea22b027ae to your computer and use it in GitHub Desktop.
Documentation: MVT Quick Reference

MVT Quick Reference

Array Insert

Inserts a single value into the passed array at the passed index.

<mvt:assign name="l.index" value="miva_array_insert( array, value, i )" />

Note: if the passed array is undefined, miva_array_insert will create the variable.

Parameters
array - An array structure.
value - Any value, either variable or literal.
i - The index to insert the value at. If -1 is used, the value will be inserted at the END of the array.
Return Values
int - The index of the inserted value.
Examples
<!-- "Push" the 'Hello' string at the end of the array -->
<mvt:assign name="l.index" value="miva_array_insert( l.settings:array, 'Hello', -1 )" />
Rosetta
  • php
    • array_push
    • array_unshift

Array Serialize

Convert a Miva array structure into a string.

<mvt:assign name="g.output" value="miva_array_serialize( array )" />

miva_array_serialize maps key -> value pairs in a comma separated string.

Parameters
array - An array structure.
Return Values
string - A string representation of the passed array.
Examples
<!-- Dump a mapped, string based representation of the "product" variable into "output" -->
<mvt:assign name="g.output" value="miva_array_serialize( l.settings:product )" />
<!-- Render output's value onto the page: -->
<!-- &mvt:global:ouput; -->
Rosetta
  • php
    • print_r
    • var_dump
    • var_export
    • serialize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment