Long series of nested conditionals

Options
I will start out by saying "I hate writing conditionals with S-tags." Confuses the heck out of me. That said, what I'm trying to do is probably a conditional nightmare.


We have a virtual giving "catalog" where each "item" is basically a different donation form. (The catalog is an LCMS page http://www.cbf.org/join-us/more-ways-to-give/cbfs-giving-catalog/ and each item links to a different LO donation form.) We created an eCard stationery for each item/donation form specific to that gift, with a specific image and specific text.


I would like to create some holiday ecard options -- for example, one with a Christmas image and one with a Hanukkah image -- but with the text remaining specific to the gift purchased.

My thought is to create each holiday stationery using conditionals for the content. For example, stationery with a Christmas image would include the following conditional scenario: If Donation Form ID is 1 then content is P; if Donation Form ID is 2 then content is Q; if Donation Form ID is 3 then content is R. I have 8 donation forms.


Is this kind of conditional even possible?


Insights appreciated.


Kim
Tagged:

Comments

  • Romany -


    This is great!! Thank you so much!


    Kim
  • Great idea, Romany! You can also pull any query string from a Luminate URL using S334, so [[S334:df_id]] will also render the donation form ID. 
  • Kim Ethridge:

    [...] Is this kind of conditional even possible? [...]

    While Romany's answer is certainly the best, to answer the broader question re: nested conditionals: I don't recall the point at which nested conditionals stop functioning, but I think 8 deep is okay. If I remember correctly, somewhere around 15, the parser starts to choke on all the data and the processing of the conditional fails to complete.

    However, if you were resigned to using conditionals, it sounds like in this case you don't actually need to nest any conditionals. Nesting conditionals is only necessary when you need to include or exclude content based on a dependent condition -- that is, if two conditions could be true at the same time, but you want one of the conditions to take priority over the other. Grammatically, it's the difference between...

    [[?x1x::x[[S120:dc:donFormID]]x::<ECARD #1 CONTENT>::<ECARD #2 CONTENT>]]<br /><br /><br/>Which can be read as "If we are using donation form #1, display content from ecard #1; otherwise, display content from ecard #2."

    ...or...

    [[?x1x::x[[S120:dc:donFormID]]x::<ECARD #1 CONTENT>::]] [[?x2x::x[[S120:dc:donFormID]]x::<ECARD #2 CONTENT>::]]<br /><br /><br/>Which can be read as "If we are using donation form #1, display content from ecard #1; otherwise, do nothing. Next, if we are viewing donation form #2, display content from ecard#2; otherwise, do nothing."

    Both of these conditionals will achieve the same effect, but because we will (should) never run into a situation where the page, email, or document thinks we're using both donation forms #1 and #2 at the same time, then nesting is unnecessary and we can just do multiple independent checks one after the other, saving ourselves some headache.

  • Great information! Thanks Mark!
  • I believe it's somewhere closer to 20 deep.


    I write them like this:

    [[?

    foobar::bar

    ::

    this::that

    ]]


    And I read this as...


    IF

    foobar CONTAINS bar

    THEN

    this OTHERWISE that


    Then nesting them looks like this...


    [[?

    foobar::bar
    ::
    this::

        [[?

        foobar::foo
        ::
        this::that
        ]]

    ]]



    Once its all written and final you can pull out the formatting and indents, but this makes it a lot easier to track.



    BTW -  Thinking 'CONTAINS' explains the whole *foobar*::*bar* business you see. The asterisks make the CONTAINS function as an EQUALS.

    bar::bar            bar CONTAINS bar is true
    foobar::bar         foobar CONTAINS bar is true

    *bar*::*bar*        *bar* CONTAINS *bar* is true
    *foobar*::*bar*     *foobar* CONTAINS *bar* is false

    Make sense? Now with a real tag rather than foobar...

    [[?
    *[S1:first_name]*::*brian*   <- won't accidently match to 'briana'
    ::
    "Yo, Bri!"::"Hello, Friend"
    ]]


    Here's another neat trick. Either/Or matches!


    [[?
    *brian*amy*::*[S1:first_name]*   <- will match to either 'brian' or 'amy'
    ::
    "Yo, Mucha!"::"Hello, Friend"
    ]]

Categories