I've been trying to figure this out for myself but I am super frustrated at this point! I've got smarty variables and conditional statements working in thank you letters. Well kind of working. Basically I'd like to include the contribution note if the note field is filled in, if it's not show the text "None". I can get the note to display but no matter what set up I've used I can't get it to show "None". I have two donations one with a note, one without. Here is what I've tried so far:
{if $note.note}I'm a note{/if} // works as expected
{if !$note.note}None{/if} // does NOT show the text none as expected
{if $note.note neq""}I'm a note{/if} // works as expected
{if $note.note eq""}None{/if} // does NOT show the text none as expected
{if $note.note}I'm a note{else}None{/if} // outputs "I'm a note" on contribution receipt with a note but still nothing on the contribution that has no note.
{if !$note.note}None{else}I'm a note{/if} // outputs "I'm a note" on contribution receipt with a note but still nothing on the contribution that has no note.
I've also tried capturing a smarty variable and then using it in the if statement.
{capture assign='note_text'}None{/capture}
{if !$note.note}{$note_text}{else}I'm a note{/if} // "None" is still not displayed as it should be.
Can anyone shed some light? (I'm sure a suggestion will be is to write some hook or custom token with this logic already worked in. But I'd really like to know why the if statement isn't working as straightforward as I'd imagined it would. I'd like to use more if statements for mailing labels etc and if I can't get an "else" to work that's a problem.)
(Wordpress 4.4.1 and Civi 4.6.4)