Email Template Keys - How to add a new one

I am trying to understand how Dolphin's email template keys work and how to add a new key.  Any help on this is greatly appreciated as always.

-GG

Geeks, making the world a better place
Quote · 5 Jul 2013

inc/classes/BxDolEmailTemplates.php

This is the function that processes the keys that are in the templates.

    function parseContent($sContent, $aKeys, $iMemberId = 0)
    {
        $aResultKeys = $this->getDefaultKeys();
        if($iMemberId != 0) {
            $aProfile = getProfileInfo($iMemberId);

            $aResultKeys = array_merge($aResultKeys, array(
                'recipientID' => $aProfile['ID'],
                'RealName'    => getNickName($aProfile['ID']),
                'NickName'      => getNickName($aProfile['ID']),
                'RecipientUrl'=> getProfileLink($aProfile['ID']),
                'Email'       => $aProfile['Email'],
                'Password'    => $aProfile['Password'],
                'SiteName'      => getParam('site_title'),
            ));
        }
        if(is_array($aKeys))
            $aResultKeys = array_merge($aResultKeys, $aKeys);

        return $GLOBALS['oSysTemplate']->parseHtmlByContent($sContent, $aResultKeys, array('<', '>'));
    }

The array contains the keys and the replacement value.

Example. <recipientID> gets replaced with the content of $aProfile['ID']
<SiteName> gets replaced with getParam('site_title') or rather the return value of the getParam function which would of course be the title of your site.

So to add a key, just add to the array.

Right after 'SiteName'      => getParam('site_title'), you would add another value.

'Token'      => $sTokenContent,


You need to make sure that before the array is loaded you need to set the content of $sTokenContent to the content you need. So just after this.

        if($iMemberId != 0) {
            $aProfile = getProfileInfo($iMemberId);

You need to place your code such as the database query code that will retrieve the proper information and load it into the $sTokenContent variable.

Then with 'Token'      => $sTokenContent, added to the array of keys to parse, <Token> will be replaced with the content of $sTokenContent.


https://www.deanbassett.com
Quote · 5 Jul 2013

Thanks, I really appreciate this.

Geeks, making the world a better place
Quote · 5 Jul 2013

 

You need to make sure that before the array is loaded you need to set the content of $sTokenContent to the content you need. So just after this.

        if($iMemberId != 0) {
            $aProfile = getProfileInfo($iMemberId);

You need to place your code such as the database query code that will retrieve the proper information and load it into the $sTokenContent variable.

Then with 'Token'      => $sTokenContent, added to the array of keys to parse, <Token> will be replaced with the content of $sTokenContent.

I placed  $sTokenContent = "Token Content" to test and it never replaced it no matter what I did.  It is now after 2 am so I am going to bed; will look at this more tomorrow.

Thanks for your help.

Geeks, making the world a better place
Quote · 5 Jul 2013

I am not sure what is happening.  The email is sent out using php sendmail() so I may just try hacking the body part of sendmail(); $aTemplate['Body'], and see if I can get the token included.  I wanted to do this the correct way.

Geeks, making the world a better place
Quote · 5 Jul 2013

What was happening is that I was working too late at night and very tired.  This works as outlined for anyone that wishes to add custom keys to the email templates.

Geeks, making the world a better place
Quote · 5 Jul 2013

This is an awesome thread.... I plan on making some modifications... :)

Thanks!

Peer

Peer L. Plaut Executive Director, Single Booklovers Connecting Bookworms Since 1970
Quote · 23 Nov 2013
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.