UNA
Loading...
Searching...
No Matches
BxDolEmailTemplates Class Reference
Inheritance diagram for BxDolEmailTemplates:
BxDolFactory iBxDolSingleton

Public Member Functions

 __clone ()
 
 getTemplate ($sTemplateName, $iAccountId=0)
 
 parseTemplate ($sTemplateName, $aTemplateKeys, $iAccountId=0, $iProfileId=0)
 
 parseContent ($sContent, $aKeys, $iAccountId=0, $iProfileId=0)
 

Static Public Member Functions

static getInstance ()
 

Protected Attributes

 $_oEmailTemplatesQuery
 
 $iDefaultLangId
 
 $iFallbackLangId
 
 $aDefaultKeys
 

Detailed Description

Email templates are used to send preformated messages.

Email templates are multilingual.

User is sent email in language which is defined in their account, if account language is not set - then default site language is used.

Email templates use template system, so it is possible to customize header/footer via Studio -> Polyglot -> Emails header/footer

1-click unsubscribe link is added automatically to every email (except a few system emails, which is not supposed to unsubscribe from, like forgot password email). Please note: make sure that {unsubscribe} marker is not removed, or unsubscribe link will not be added.

Example of usage

Send an email using email templates:

// define custom template variables
$aPlus = array();
$aPlus['email'] = 'ktoto@example.com';
$aPlus['conf_code'] = '123456';
$aPlus['conf_link'] = BX_DOL_URL_ROOT . 'page.php?i=confirm-email&code=123456';
$aPlus['conf_form_link'] = BX_DOL_URL_ROOT . 'page.php?i=confirm-email';
$aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('t_Confirmation', $aPlus); // get class instance and parse template
if ($aTemplate && sendMail('ktoto@example.com', $aTemplate['Subject'], $aTemplate['Body'])) // send email if template exists
echo 'email was successfully sent';
else
echo 'email send failed';
static getInstance()
Definition BxDolEmailTemplates.php:89
sendMail($mRecipientEmails, $sMailSubject, $sMailBody, $iRecipientID=0, $aPlus=array(), $iEmailType=BX_EMAIL_NOTIFY, $sEmailFlag='html', $isDisableAlert=false, $aCustomHeaders=array(), $bAddToQueue=false)
Definition utils.inc.php:397

Constructor & Destructor Documentation

◆ __construct()

BxDolEmailTemplates::__construct ( )
protected

Reimplemented from BxDolFactory.

Member Function Documentation

◆ __clone()

BxDolEmailTemplates::__clone ( )

Prevent cloning the instance

◆ getInstance()

static BxDolEmailTemplates::getInstance ( )
static

Get singleton instance of the class

Implements iBxDolSingleton.

◆ getTemplate()

BxDolEmailTemplates::getTemplate ( $sTemplateName,
$iAccountId = 0 )

Function will return array of needed template ;

Parameters
string$sTemplateName- name of necessary template.
integer$iAccountId- account ID of registered member.
Returns
array with template 'Subject' and 'Body'.

◆ parseTemplate()

BxDolEmailTemplates::parseTemplate ( $sTemplateName,
$aTemplateKeys,
$iAccountId = 0,
$iProfileId = 0 )

Function will return array of needed template with neccessary markers replaced ;

Parameters
string$sTemplateName- name of necessary template.
string$aTemplatekeys- key ane value pairs to replace in subject and body.
integer$iAccountId- account ID of registered member.
integer$iProfileId- profile ID of registered member.
Returns
array with template 'Subject' and 'Body'.

Hooks:

'system', 'parse_email_template' - hook on template with neccessary markers replaced

  • $unit_name - equals system
  • $action - equals parse_email_template
  • $object_id - not used
  • $sender_id - not used
  • $extra_params - array of additional params with the following array keys:
    • template_name - [string] by ref, name of necessary template, can be overridden in hook processing
    • template_keys - [array] by ref, key ane value pairs to replace in subject and body, can be overridden in hook processing
    • account_id - [int] by ref, account ID of registered member, can be overridden in hook processing
    • profile_id - [int] by ref, profile ID of registered member, can be overridden in hook processing
    • template - [array] by ref, template, can be overridden in hook processing
      HOOKS
      'system', 'parse_email_template' - hook on template with neccessary markers replaced

The documentation for this class was generated from the following file: