Skip to content

Miva Structures#


In Miva Template Language, a structure serves as a foundational data object for organizing and managing data. Analogous to record or struct types in other programming languages, structures in Miva enable the encapsulation of distinct data elements within individual fields. These fields can encompass various data types such as strings, integers, or even nested structures, facilitating a hierarchical data organization approach.

l.settings#

One prominent instance of a structure within Miva is the l.settings structure, which functions as a specialized repository. Any variables assigned to this structure automatically become accessible within the page template language. Module developers can easily expose their variables for utilization in page templates by incorporating them into the l.settings structure. Upon page load, Miva Merchant initializes the l.settings structure with all pertinent variables defined within the page template.

Miva Structure

For instance, consider illustration above: the l.settings structure contains two principal members, namely store and page. Although, in actuality, it encompasses a more extensive array of variables, for visualization purposes, we’ll focus on these two. The store structure comprises variables such as code, city, currency, and phone, each drawn from configurations specified in the Miva Merchant Admin under Store Settings. Meanwhile, the page member contains details regarding the rendered page, including code, ID, and name.

Given that these variables are encompassed within the l.settings structure, they are readily accessible throughout the page template, akin to global variables. To output these variables onto the page, the &mvt: prefix, which is typically required for global variables, is unnecessary. Instead, referencing the structure followed by the specific variable path suffices. For instance, to output the store code, one simply uses &mvt:store:code;, without the need for a prefix. Similarly, for page-related variables, such as &mvt:page:name;, the same convention applies.

When conditionally evaluating variables within the l.settings structure, the full path to the variable is specified, such as “l.settings:page:code. This approach ensures precise referencing and comparison. The l.settings structure constitutes a fundamental component of the Miva Merchant template language, extensively utilized across various page templates. Acquiring proficiency in its usage significantly enhances comprehension and readability of Miva Merchant’s template language.