Conditional Nesting syntax for XML S-tags

Options
It isn't at all clear from the documentation how to nest conditionals, particularly using the XML syntax (which I much prefer).

I'll omit the brackets and put spaces between the convio: and the thing because I'm sick of the forum software turning everything into 'surprisesmileyface' that happens whenever you do "convio: op".


I have a convio:choose block.  I need to test for both  dc:transactionID nempty AND dc:isGiftAmountGreaterThan:60 true -- both conditions need to be true for me to do my desired output.  


Should it look like this?

convio: choose

  convio: when test="nempty"

  convio: op   convio: session name="120" param="dc:transactionID" /convio: session /convio: op

  convio: then

    convio: when test="true"

    convio: op convio: session name="120" param="dc:isGiftAmountGreaterThan:60" /convio: session /convio: op

    convio: then

      Print out the thing I want to print out

    /convio: then

   /convio: when

 /convio: then

 /convio: when

/convio: choose


BTW, it would be really awesome if there were some way to group conditionals with 'and'.

Also related, "isGiftAmountGreaterThan" doesn't seem to actually be documented other than as an example in the S-Tag reference.  I'm assuming that the number value is a dollar amount.  I sure hope it is.

 
Tagged:

Comments

  • Why test for the transaction at all? If you're already returning an empty result for gifts below $60, wouldn't that cover your missing transactions?


    Page 131 of the S-Tags PDF documentation does have a list of different objects (at least, the copy I have does). Just do a search for "S120 Display Application Objects". I'd recommend creating a test page and just trying different options.


    I haven't tested this, but another forum post said you can nest conditionals by adding a second "choose" tag. So, it'd be:

    convio: choose

      convio: when title="TID Exists" test="nempty"

        convio: op

          convio: session name="120" param="dc:transactionID" /convio: session

        /convio: op

        convio: then

          convio: choose

            convio: when title="Gift 60" test="true"

              convio: op

                convio: session name="120" param="dc:isGiftAmountGreaterThan:60" /convio: session

              /convio: op

              convio: then

                Print the thing

              /convio: then

            /convio: when

          /convio: choose

        /convio: then

      /convio: when

    /convio: choose


    For what it's worth, that same huge block of code looks like this in bracket format...

      
    [[?
          x[[E130:[[S120:dc:transactionID]] 0 >]]x x[[E130:[[S120:dc:GiftAmount]] 60 >]]::
          x1x x1::
          Print the thing ::

      
    ]]

    Folks seem to prefer bracket syntax, especially if you're nesting conditionals. XML is already verbose, and only gets crazier when the logic is complicated. Unless you need to make a WYSIWYG representation of your logic, bracket is a lot more concise and easier to read.

    In general, syntax is just...
         [[? xIFx :: xFOOx :: TRUE :: FALSE ]]

    ...AND conditionals can be done by doubling-up on your test conditions...
         [[? xIF(1)xIF(2)x :: xFOOxBARx :: AND_TRUE :: FALSE ]]

    ...ELSE can be done by nesting a second test inside of your FALSE result...
         [[? xIFx :: xFOOx ::
             IF_TRUE ::
             [[? xELSEx :: xBARx :: ELSE_TRUE :: FALSE ]]
         ]]

    Eduardo Garcia's Conditional Pal could be helpful for testing, though I haven't really played with it much. He's also got a tool for E130 (pre-processing) tags. He's got both projects on his github.

Categories