I want to provide a default value for tokens when the value is empty, on a per-use basis -- e.g., something like {contact.first_name?Friend}
would print the contact's First Name if it's not empty, otherwise print "Friend".
Rationale update: This would allow non-programmers to easily specify a default value without needing to clutter up the tokens UI.
Existing workarounds for this functionality are more cumbersome than that:
- Dave's blog from version 2.2 uses hooks in an extension to hard-code defaults for specific tokens in all cases.
- This SE answer points out that this can be achieved by enabling Smarty processing and then inserting a few lines -- per token -- of Smarty code into the content.
To avoid double-work and/or undertaking the impossible, I ask:
Has any attempt been made to put such per-use-default-value functionality into CiviCRM core or an extension?
Technical challenges update: Tokens are limited to \w
characters, so any plan to use a non-word delimiter like ?
will have to involve changes in core, as far as I can see.