XF 2.0 Email variables

AndyB

Well-known member
I would like to personalize the email.

Email template:

Code:
<mail:subject>
{{ phrase('contact_email_subject', {
	'subject': $subject,
	'board_title': $xf.options.boardTitle
}) }}
</mail:subject>

<h2>{$subject}</h2>

<xf:if is="$xf.options.inactiveMembersImageUrl != ''">
	<img src="{$xf.options.inactiveMembersImageUrl}" alt="image" />
</xf:if>

<br />

{{ phrase('inactivemembers_message') }}

<br />

<xf:foreach loop="$threads" value="$thread">
	{$thread.forumTitle}
	<br />
	<a href="{{ link('threads/', $thread|censor) }}">{$thread.title|censor}</a>	
	<br />
	<br />
</xf:foreach>

The inactivemembers_message phrase:

Code:
Hi {username},
<br /><br />
We look forward to seeing you at {board_title}.
<br /><br />
Some of our latest topics include:

What do I have to do in order to make these two variables work?

Thank you.
 
I'm just guessing here, but wouldn't you change the line:

PHP:
{{ phrase('inactivemembers_message') }}


... to be ...

PHP:
{{ phrase('inactivemembers_message', {
    'username': $xf.visitor.username,
    'board_title': $xf.options.boardTitle
}) }}


??

I'm not sure if $xf.visitor.username will be the value you want for username though.
 
Got it:

Code:
<mail:subject>
{{ phrase('contact_email_subject', {
	'subject': $subject,
	'board_title': $xf.options.boardTitle
}) }}
</mail:subject>

<h2>{$subject}</h2>

<xf:if is="$xf.options.inactiveMembersImageUrl != ''">
	<img src="{$xf.options.inactiveMembersImageUrl}" alt="image" />
</xf:if>

<br />

{{ phrase('inactivemembers_message', {
	'username': $username,
	'board_title': $xf.options.boardTitle
}) }}

<br /><br />

<xf:foreach loop="$threads" value="$thread">
	{$thread.forumTitle}
	<br />
	<a href="{{ link('threads/', $thread|censor) }}">{$thread.title|censor}</a>	
	<br />
	<br />
</xf:foreach>

<a href="{{ link('account/preferences') }}">{{ phrase('inactivemembers_unsubscribe_link') }}</a>

The variable $username is populated in the PHP code.
 
  • Like
Reactions: Sim
Top Bottom