Announcement

Collapse
No announcement yet.

shorthand for multiple OR conditions in expression?

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

  • habreu
    replied
    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.

    Leave a comment:


  • Kent Multer
    replied
    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."

    Leave a comment:


  • Scot - ScotsScripts.com
    replied
    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.

    Leave a comment:


  • habreu
    replied
    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. :)

    Leave a comment:


  • Scot - ScotsScripts.com
    replied
    <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>

    Leave a comment:


  • habreu
    started a topic shorthand for multiple OR conditions in expression?

    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>
Working...
X