Miva Merchant Quick Tip: Some Handy Conditionals

Miva Merchant users and developers frequently post on the Miva Merchant User Forums looking for guidance with some commonly desired conditionals to control the display of content on their ecommerce sites.

Below is a list of some of the more common requests, gathered together in one handy spot. Who knows, you may even see something here that sparks an idea for modifying your own store.

Conditionals for displaying products and their information

Only show certain content for a single product

<mvt:if expr="l.settings:product:code EQ 'MyProductCode'">
My special content here
The content for all the other products

Hide a product from display (for instance, in search results or on a category page

<mvt:foreach iterator="product" array="products">
<mvt:if expr="l.settings:product:code NE 'MyProductCode'">
Product Display Information Here

Hide a set of products from display. If you name each product with a specific prefix (this example assumes the prefix is separated from the code by a hyphen), hiding them from display can be easy

<mvt:if expr="NOT('MySpecialPrefix-' CIN l.settings:product:code)">
Display some content

Display certain content only if a product has attributes

<mvt:if expr="l.settings:attr_count GE 1">
Display this content only if the product has attributes

Logged in Customers

Display certain content if a shopper is logged in to an account

<mvt:if expr="basket:cust_id">
You're logged in.

Display certain content if a shopper is logged in, and alternate content if they are not

<mvt:if expr="basket:cust_id">
You're logged in.
You're not logged in.

Secure page content

Exclude content from secure Miva Merchant pages

<mvt:if expr="NOT g.Secure">
My content that I don't want on secure pages

Include content only on secure Miva Merchant pages

<mvt:if expr="g.Secure">
My content that I only want on secure pages

Controlling Content on Specific Pages/Screens

Include content only on a specific screen

<mvt:if expr="g.Screen EQ 'MyScreen'">
My content that I only want on a specific page

Exclude content from a specific screen

<mvt:if expr="g.Screen NE 'MyScreen'">
My content that I only want on a specific page

Include content on several specific screens

<mvt:if expr="g.Screen IN 'MyScreen,MyScreen2,MyScreen3,MyScreen4'">
My content that I only want on a specific page

Exclude content from several specific screens

<mvt:if expr="NOT(g.Screen IN 'MyScreen,MyScreen2,MyScreen3,MyScreen4')">
My content that I only want on a specific page

I hope to add to this post as I think of additional common needs for Miva Merchant store morph technology conditionals, so be sure to subscribe and get any updates.

P.S. Special thanks to the fine folk at accessify.com for their brilliant Quick Escape tool which converts raw HTML to escape characters

  • 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>