| By: Brennan Heyde | Published On: 11/07/2007 |
Because Miva Merchant uses its own programming language (MivaScript) it does not allow developers to use standard PHP constructs such as if / else statements. In order to achieve the functionality of these necessary constructs, Miva 5 has its own pseudo scripting language. These scripting conditionals are part of Miva 5’s built in Store Morph Technology (SMT).
As you start to build more and more complex Miva stores, you will find that these conditionals become very handy. Below are some simple examples of conditionals available in Miva 5.
Standard If/Else Statement
<mvt:if expr="g.Category_Code EQ 'TEST' ">
//execute this code only on TEST category
<mvt:else>
//do this when not on TEST category
</mvt:if>
You can use the same code slightly modified, to see which screen you are on. This is useful if you want to display something only on the homepage (SFNT)
<mvt:if expr="g.Screen EQ 'SFNT' ">
//execute this code only on SFNT page
<mvt:else>
//do this when not on SFNT page
</mvt:if>
This code will display a different My Account link depending on if a user is logged in or not. When a user is not logged in, it will send them to the login page. If they are already logged in, it will send them to their Account page.
<mvt:if expr="g.Basket:cust_id EQ 0">
<a href="&mvt:global:secure_sessionurl;Screen=LOGN&Order=0&Store_Code=&mvt:global:Store_Code;" class="checkout" > MY ACCOUNT</a>
<mvt:else>
<a href="&mvt:global:secure_sessionurl;Screen=ACNT&Order=0&Store_Code=&mvt:global:Store_Code;" class="checkout">MY ACCOUNT</a>
</mvt:if>
The following code will display a personalized greeting when a user is logged in. If they are not logged in, it will display , “Welcome, Guest. Please Login.”
You can read the full tutorial for this login script here.
<mvt:if expr="g.Basket:cust_id EQ 0">
Welcome, Guest. Please Login.
<mvt:else>
Welcome Back, &mvt:global:customer:ship_fname;
<a href="https://www.YOURSTORE.com/mm5/merchant.mvc?Action=LOGO&Screen=SFNT&Store_Code=S" style="color:#FFCC00">Logout</a>
</mvt:if>
One of the nice features with Miva Merchant 5 is that is has a lot of built in local and global variables which you can access from most pages within Miva. Latu.net has a great free module called, Store Helper Module v5 which will show you all the variables you can access. I highly recommend it.
Miva Merchant has a great page about Store Morph Technology - You can find it Here
About the Author: Brennan Heyde is an e-commerce consultant working in San Diego, Ca. He specializes in online marketing and SEO for e-commerce. Have a struggling e-commerce website? – Contact Brennan today for a site analysis.
















