Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Email->populateTemplate() with multiple objects


Go to End


2 Posts   1800 Views

Avatar
dio5

Community Member, 501 Posts

28 October 2007 at 10:10pm

How can I do Email->populateTemplate() with multiple objects?
In the docu http://doc.silverstripe.com/assets/classes/default/Email_Template.html#populateTemplate
it says we can call it multiple times, but how does the template discern different variables?

Suppose I have

$mail->populateTemplate($pageAuthor);
$mail->populateTemplate($comment);

where both $pageAuthor and $comment have a $Username variable.

How can I let the emailtemplate know when to use what?
I suppose <% control %> wouldn't work?

Avatar
dio5

Community Member, 501 Posts

28 October 2007 at 11:31pm

A possible solution: just collect the vars you want in a new Array with different names and populate the template with that array.

:-)