Miva Merchant: A Store Morph Technology Mini-Primer

Store Morph Technology
When Miva Merchant released MM5, they revolutionized the way the software worked “out of the box” and opened a whole new world of customization to ecommerce store owners. Using Store Morph Technology (SMT), store owners could completely and…well, I was going to say easily customize their stores to suit their needs, but the truth is that at first glance, SMT isn’t in fact all that easy.

One of the common complaints from new developers of MM sites, is the lack of documentation about SMT and how it works. The new owners of Miva Merchant are working hard to remedy the documentation void, but in the meantime, here’s a mini primer on SMT and some examples of the things you can do with it.

You’ll see SMT in MM’s page templates in a variety of different forms.

Variables

There are two types of variables in SMT: local variables, specific to the page you’re on, and global variables, which are available sitewide. The best way to find out what variables are available on a given page is to download the free Store Helper Module from Latu.net.

Variables are displayed on MM pages in a variety of ways. Note that variables always begin with an ampersand (&) and end with a semicolon (;).

&mvt:product:code;
&mvte:product:code;
&mvta:product:code;

Variables that begin with &mvte are “entity encoded.” This means that any characters they contain will be displayed on the page in their exact form — they will not be interpreted by the browser.

Variables that begin with &mvta are “attribute encoded.” This means that any characters they contain will be converted to the correct format for use in a link.

Tags

SMT tags look similar to XHTML tags in that they are surrounded by < >, they include name / value pairs, with the values surrounded by double quotes, and all SMT tags must be closed, either by using a trailing slash, or with a separate closing tag.

Items

SMT tags may call in specific page items. These tags start with mvt:item, and use name=”xyz” to identify which page item is being called. They may also include parameters that more specifically identify the content to be called in. They are frequently self closing, but may have a separate closing tag depending on their form.

<mvt:item name="html_profile" />

<mvt:item name="fonts" param="body_font" />
Some content here
</mvt:item>

Loops and arrays

SMT tags may be used to loop through an array, and display specific data associated with that array. Common uses for these tags include such things as displaying the products in a category or search result, listing all of the products in the basket, or listing available shipping methods. All loops must be closed with a separate closing tag after you’ve worked with the content you’re pulling from the array.

<mvt:foreach iterator="product" array="products">
Some stuff about each of the items in this array
</mvt:foreach>

Conditionals

Finally, SMT tags may be used to create conditionals. This is far and away one of the most useful aspects of SMT, and is the building block of the store owner’s ability to customize his or her store (at least in my opinion!). Writing conditionals is probably worthy of a post all its own, but here are some basics.

All conditionals start with mvt:if and contain an expression to test for. A very basic conditional might look like this. This conditional checks to see if the product code is equal to the string 12345, and if it is, displays some text. Note that the string is enclosed in single quotes.

<mvt:if expr="l.settings:product:code EQ '12345'">
Display some text.
</mvt:if>

Conditionals can also be set up to do one thing if the condition is true, and another thing if it is false.

<mvt:if expr="l.settings:product:code EQ '12345'">
Display some text.
<mvt:else>
Display some other text.
</mvt:if>

Or even…

<mvt:if expr="l.settings:product:code EQ '12345'">
Display some text.
<mvt:elseif expr="l.settings:product:code EQ '45678'">
Display some other text.
<mvt:else>
Display yet some other text.
</mvt:if>

Expressions can be combined to create extremely specific situations to test against. For instance, if you want to display some text only if the product code is 12345 and the customer is logged in, you would write your conditional something like this:

<mvt:if expr="((l.settings:product:code EQ '12345') AND (g.Basket:Cust_id))">
Display some text
</mvt:if>

You can also easily test for a match in a single string or a series of strings, by using CIN or IN. CIN is case insensitive; IN is case sensitive. The strings to test against are enclosed in single quotes, and if there is more than one, they are separated by commas or some other delimiter such as a pipe. The conditional below will return true if the product code is 12345 or 45678 or 67890.

<mvt:if expr="l.settings:product:code IN '12345,45678,67890'">
Display some text.
</mvt:if>

Note that the conditional above will also return true if the product code is 1234567, 012345, or 98712356789. It checks merely to see if the content of the first variable is included in the second. If you need to look for an exact match, you would be better to use a conditional like the following.

<mvt:if expr="((l.settings:product:code EQ '12345') OR (l.settings:product:code EQ '45678') OR (l.settings:product:code EQ '67890'))">
Display some text.
</mvt:if>

Once you get the hang of them, you’ll wonder how you ever did without the power of conditionals to control your shopper’s experience on your site. Below are some of the most common conditional operators, along with what they do.

Operator Function
NOT Returns true if the condition does not match the variable
ISNULL Returns true if the variable is empty
AND Returns true if both conditions are true
OR Returns true if any of the conditions is true
EQ Returns true if the variable matches the string
NE Returns true if the variable does not match the string
GT Returns true if the variable is greater than the string
LT Returns true if the variable is less than the string
GE Returns true if the variable is greater than or equal to the string
LE Returns true if the variable is less than or equal to the string
IN Returns the first position of string_a in string_b. Case sensitive
CIN Returns the first position of string_a in string_b. Case insensitive

Comments

Finally, one of the most useful, and underused in my opinion, features of SMT is the comment feature. By carefully commenting your work, you make it so much easier on yourself or another developer when it comes time to try to make updates or changes to existing customizations. SMT comments take the following form. They are not parsed by the server, and won’t appear in your html source code.

<mvt:comment>
Here is an explanation of what this section of code is going to do.
</mvt:comment>
  • Twitter
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Yahoo! Bookmarks
  • Technorati

Leave a Reply

HTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>