walther
walther

Reputation: 13600

Populating mandrill template using php API and merge_vars

As we know, when using templates, we specify vars like this:

'global_merge_vars' => array(
      array(
          'name' => 'my first var',
          'content' => 'content i want to display'
      )
),

This is nice and all, but becomes a pain if I want to use handlebars to display lists of information (arrays) in my email. I have to create a function to parse the list of data to meet this name-content format criteria. Is there any way around that I'm missing? I'd really like to do something like this:

'global_merge_vars' => array(
      array(
          'name_of_var' => 'value',
          'some_array_name' => $myArray,
          'other_array' => $otherArray
      )
),

Upvotes: 0

Views: 589

Answers (1)

Alex Tartan
Alex Tartan

Reputation: 6836

As the docs point out, that's the way the API is expecting that parameter.

The send function from the Mandrill_Messages class has this in the docblock:

 *     - global_merge_vars array global merge variables to use for all recipients. You can override these per recipient.
 *         - global_merge_vars[] struct a single global merge variable
 *             - name string the global merge variable's name. Merge variable names are case-insensitive and may not start with _
 *             - content mixed the global merge variable's content

Maybe write an email to Mandrill, although i doubt they'll consider any changes to their API.

Upvotes: 1

Related Questions