Announcement

Collapse
No announcement yet.

shorthand for multiple OR conditions in expression?

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

    shorthand for multiple OR conditions in expression?

    Baby question but I couldn't find this in the developer doc section;

    Instead of multiple OR condtions is there a short hand something like

    /* if any of the following EQ 1 then do something */
    <mvt:if expr="'g.abc|g.def|g.ghi' EQ 1">
    found - do something
    <mvt:else>
    not found - do something else
    </mvt:if>

    #2
    <mvt:if epxr="g.abc EQ 1 OR g.def EQ 1 OR g.ghi EQ 1">
    do something
    <mvt:else>
    do nothing
    </mvt:if>
    M.A.D.* since 1997

    http://www.scotsscripts.com

    *miva application developers

    Comment


      #3
      Okay thanks I thought there might be something even tighter. Just because this started out as one check and now the boss is asking for a couple more and I see where he is headed. :)

      Comment


        #4
        You can do something different that is tighter.

        <mvt:assign name="l.codes_to_check" value=" '|abc|def|ghi|jkl|'" />

        So if the "l.code" is set to one of those, you can do:

        <mvt:if expr="l.code CIN l.codes_to_check">
        do something
        </mvt:if>

        Not sure of your application, but a lot of devs do this method when they need to make a list of codes to check against.
        M.A.D.* since 1997

        http://www.scotsscripts.com

        *miva application developers

        Comment


          #5
          If the variables you're checking are Boolean, i.e. always one or zero, then you can write
          Code:
          <mvt:if expr="g.abc OR g.def OR g.ghi">
          In the Miva world, zero and empty-string are "False," and any other value is "True."
          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


            #6
            Thank you Scot and Kent. Both useful.

            Just fyi I am just using a bit of Tool Belt code

            <mvt:item name="ry_toolbelt" param="availgroup|Customer_Find|g.essfound|'Extra Space Availability Group'" />
            <mvt:if expr="g.essfound EQ 1">

            and use the 'found' value on various pages to redirect people who login and are a member of the group to their own category and I hide the other menu options, show their logo and some custom text. It was originally just for one customer but the boss offered it to a couple more which is why I'm having a second look at it and documenting it better as well.

            Thanks again.

            Comment

            Working...
            X