Announcement

Collapse
No announcement yet.

Need To Shorten Conditional

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need To Shorten Conditional

    I have the following conditional to hide loyalty points from displaying on the product page. I need to add additional products to this. Can someone advise as how to possibly shorten this? Appreciate the help.

    <mvt:if expr="(l.settings:product:code NE 'e-gift-cert' AND l.settings:product:code NE 'gift-cert' AND l.settings:product:code NE 'HKW-1' AND l.settings:product:code NE '662434-83' AND l.settings:product:code NE 'O17-1')"></mvt>

    #2
    This is a bit convoluted, but it's what I do in that situation:
    Code:
    <mvt:if expr="NOT ( (',' $ l.settings:product:code $ ',') CIN (',e-gift-cert,gift-cert,HKW-1,662434-83,O17-1,AnotherCode,OneMoreCode,YetAnotherCode,EtcEtc,') )">
    The extra commas are needed so that it won't accidentally detect a short code that happens to be a substring of a larger one in the list. Note that there are commas at the beginning and end of both strings.
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    Comment


      #3
      Thanks Kent.

      Comment


        #4
        Yes, this is how it always should be done. If this is something an Admin may want to update, we'd typically write it like this:

        Code:
        <mvt:assign name="g.dont_show_points" value="'this_code, that_code, another_code'" />
        
        <mvt:if expr="NOT(', ' $ l.settings:product:code CIN g.dont_show_points)">
        points
        </mvt:if>
        this, in our experiance, makes Admin entry less prone to breaking things. At most, you get a false 'positive' in stead of breaking the conditional altogether.
        Bruce Golub
        Phosphor Media - "Your Success is our Business"

        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
        phosphormedia.com

        Comment

        Working...
        X