eCard message conditional - how to?

Options

Under Email/Stationary - basic eCard

statement <convio:session name="63" param="2"></convio:session> pulls in a message from forms eCard message variable.

What is the proper syntax for creating a conditional to test if the eCard message is not empty?

I would like to display a message title if it exists, otherwise no message title display.

Here is pseudo-code of what I would like to do:

if "eCard message" is not empty then

   <br /><strong>Personal Note:</strong><br/>"

end

<convio:session name="63" param="2"></convio:session>

Thanks,

-serge

Tagged:

Comments

  • Serge,

    This is a little tricky. The Ecard content rendered with the S63 tag includes an intro line, "A message from <<sender name>> <<sender email>>", so S63 is actually never empty.

    The only solution I can think of is to use JavaScript on the Ecard form to set a session variable indicating whether or not the sender has filled in a message. That would look something like this:



    <img id="AjaxHelper" alt="" width="1" height="1" style="position:absolute;left:-999em;" src="AjaxHelper?s_isMessageEmpty=1" />
    <script type="text/javascript">
    var messageIsEmpty=true;
    function isMessageEmpty(){
    var ecardMessage=document.getElementById('message');
    var ajaxHelper=document.getElementById('AjaxHelper');
    if(ecardMessage.value==''&&!messageIsEmpty){
    ajaxHelper.src='AjaxHelper?s_isMessageEmpty=1';
    messageIsEmpty=true;
    }
    else if(ecardMessage.value!=''&&messageIsEmpty){
    ajaxHelper.src='AjaxHelper?s_isMessageEmpty=0';
    messageIsEmpty=false;
    }
    }
    addOnLoadHandler(function(){
    var ecardMessage=document.getElementById('message');
    isMessageEmpty();
    Utils.addEvent(ecardMessage,'keyup',isMessageEmpty);
    });
    </script>

    Then in the Ecard stationery, you'd use a conditional like this to test the session variable's value:



    ]x::<br /><strong>Personal Note:</strong><br/>::]]
    ]

    Note that the "Personal Note:" text will appear above the aforementioned "A message from <<sender name>> <<sender email>>" text. If you want "Personal Note" to appear directly above the Ecard message itself, the conditional would need to go in the Message Catalog entry for "A message from {0} {1}."

  • Noah Cooper:

    Serge,

    This is a little tricky. The Ecard content rendered with the S63 tag includes an intro line, "A message from <<sender name>> <<sender email>>", so S63 is actually never empty.

    The only solution I can think of is to use JavaScript on the Ecard form to set a session variable indicating whether or not the sender has filled in a message. That would look something like this:



    <img id="AjaxHelper" alt="" width="1" height="1" style="position:absolute;left:-999em;" src="AjaxHelper?s_isMessageEmpty=1" />
    <script type="text/javascript">
    var messageIsEmpty=true;
    function isMessageEmpty(){
    var ecardMessage=document.getElementById('message');
    var ajaxHelper=document.getElementById('AjaxHelper');
    if(ecardMessage.value==''&&!messageIsEmpty){
    ajaxHelper.src='AjaxHelper?s_isMessageEmpty=1';
    messageIsEmpty=true;
    }
    else if(ecardMessage.value!=''&&messageIsEmpty){
    ajaxHelper.src='AjaxHelper?s_isMessageEmpty=0';
    messageIsEmpty=false;
    }
    }
    addOnLoadHandler(function(){
    var ecardMessage=document.getElementById('message');
    isMessageEmpty();
    Utils.addEvent(ecardMessage,'keyup',isMessageEmpty);
    });
    </script>

    Then in the Ecard stationery, you'd use a conditional like this to test the session variable's value:



    ]x::<br /><strong>Personal Note:</strong><br/>::]]
    ]

    Note that the "Personal Note:" text will appear above the aforementioned "A message from <<sender name>> <<sender email>>" text. If you want "Personal Note" to appear directly above the Ecard message itself, the conditional would need to go in the Message Catalog entry for "A message from {0} {1}."

    Thanks Noah,

    that is tricky!

    Perhaps there is a less complex way..

    I am thinking that perhaps I would like to test the message for emptyness on the form (I use API, so have full control of the client side)

    and insert a key string into the message if message on the html form is not empty, say ***.

    On html API form:

    Something like this:

    <script>

    var o = getObject('ecard.message');

    if( o ) {

        if( o.value != '' ) then o.value = '***'+o.value;

    }

    </script>

    Then on eCard side do something like this (pseudocode):

    if ecardMessage.contains("***") then

       print "<br /><strong>Personal Note:</strong><br/>"

       print ecardMessage

    end if

    How would I test the message for a presence of ***, and then display a title?

    Thanks,

    -serge

  • Serge Tkachov:

    Thanks Noah,

    that is tricky!

    Perhaps there is a less complex way..

    I am thinking that perhaps I would like to test the message for emptyness on the form (I use API, so have full control of the client side)

    and insert a key string into the message if message on the html form is not empty, say ***.

    On html API form:

    Something like this:

    <script>

    var o = getObject('ecard.message');

    if( o ) {

        if( o.value != '' ) then o.value = '***'+o.value;

    }

    </script>

    Then on eCard side do something like this (pseudocode):

    if ecardMessage.contains("***") then

       print "<br /><strong>Personal Note:</strong><br/>"

       print ecardMessage

    end if

    How would I test the message for a presence of ***, and then display a title?

    Thanks,

    -serge

    You could do that like so:



    ]::***::::<br /><strong>Personal Note:</strong><br/>]]
    ]

    Bearing in mind the issue I noted before -- this text will appear above "A message from ..."

Categories