Fallback for placeholders in Newsletters

5 posts by 3 authors in: Forums > CMS Builder
Last Post: March 2, 2020   (RSS)

By JeffC - February 13, 2020

Hi

Is it possible to create a fallback for instances where you do not have information in a field.

For example:

Dear #contact.name#

Would appear as:

Dear Colleague

Where contact.name is empty.

Thanks

Jeff

Jeff

Try this

<?php // if record show this
 if ($record['record']): ?>
<?php echo htmlencode($record['record']) ?>

<?php // if no record show this
 else: ?>
<?php echo "Colleague"; ?>
<?php endif ?>

By JeffC - February 15, 2020

Thanks Alan

I am hoping that there is a function to provide a fallback directly in the Newsletter.

When compiling a newsletter, to include a persons name, you would literally (no php in the newsletter itself) write: #name#

I used to use Campaign Monitor to deliver my emails. It has has a similar format for Placeholders, and had a function to provide a fallback in the placeholder itself. Placeholders in CM look like this: [firstname,fallback=Colleague]

Do you know if there is anything similar in cmsb?

Thanks

Jeff

By JeffC - March 2, 2020

Exactly what I was after, thanks Greg

Jeff