Is it possible to use variables in an email template?

3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 6, 2018   (RSS)

By daniel - November 6, 2018

Hi Jerry,

The email templates don't support PHP code, but you can use that if/else idea to create a variable to send in as the placeholder instead. It could look something like this:

<?php

  $example    = !empty($_REQUEST['example']) ? $_REQUEST['example'] : false;
  $placholder = '';

  if ($example === 0) {
    $placeholder = 'some text';
  }
  elseif ($example === 1) {
    $placeholder = 'other text';
  }

  $emailHeaders = emailTemplate_loadFromDB(array(
    'template_id'       => 'EXAMPLE-TEMPLATE-ID',
    'placeholders'      => array(
      'placeholder' => $placeholder,
    ),
  ));      
?>

You'll need to modify it to suit your code, but I hope that gets the basic idea across.

Let me know if you have any questions!

Thanks,

Daniel
Technical Lead
interactivetools.com

Thanks Daniel,

I kind of figured that, but was hoping for an easy...

Jerry

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php