Functions Overview#
The Miva Empressa engine powers the core functionality of Miva Merchant, offering a robust suite of functions for string manipulation, file handling, time management, and more. These functions enable developers to extend the capabilities of templates and create dynamic, responsive storefronts.
This section introduces some of the most commonly used functions and their applications.
Key Functions#
gettoken
#
The gettoken
function splits a string into tokens based on a delimiter and retrieves the specified token.
Example:
<mvt:assign name="g.list" value="'apples,oranges,bananas'" />
<mvt:assign name="g.first" value="gettoken(g.list, ',', 1)" />
<p>First Item: &mvt:global:first;</p>
Output:
First Item: apples
glosub
#
The glosub
function replaces all occurrences of a substring within a string.
Example:
<mvt:assign name="g.string" value="'Miva Merchant 9 is amazing!'" />
<mvt:assign name="g.new_string" value="glosub(g.string, '9', '10')" />
<p>Updated String: &mvt:global:new_string;</p>
Output:
Updated String: Miva Merchant 10 is amazing!
substring
#
The substring
function extracts a part of a string based on a starting position and length.
Example:
<mvt:assign name="g.full_string" value="'Welcome to Miva!'" />
<mvt:assign name="g.sub" value="substring(g.full_string, 11, 4)" />
<p>Extracted: &mvt:global:sub;</p>
Output:
Extracted: Miva
Summary#
Miva Empressa’s built-in functions provide powerful tools for manipulating strings, files, and data. By mastering these functions, developers can build dynamic templates and streamline operations.
Continue to File Handling → to explore how to work with files in Miva Merchant.