Email Customizer [Deleted]

Is there a version of this for xF2?

We mainly need the Replacement variable to convert smilies in email notifications.
 
No, its not available for XF2.

To replace smilies you can try using templater_template_post_render event. XenForo 2 uses same template engine for emails as for pages, so it might work.
 
Create custom add-on, create php file within that add-on. For example, lets call add-on SonnieMail, php file Listener.php, so file location is src/addons/SonnieMail/Listener.php. Inside that file put function to listen to templater_template_post_render event:
Code:
<?php

namespace SonnieMail;

class Listener
{
   public static function templatePostRender(\XF\Template\Templater $templater, $type, $template, &$output)
   {
      if ($type !== 'email') {
         return;
      }
      $output = strtr($output, [
         ':smilie1:' => 'replacement',
         ':smilie2:' => 'another replacement',
      ]);
   }
}
Change replacements in that array. Key is string to replace, value is replacement.

To create add-on enable developer mode by adding this to src/config.php
Code:
$config['development']['enabled'] = true;

To create add-on use console. Type
Code:
php cmd.php xf-addon:create
For add-on id enter SonnieMail, for other fields enter whatever you want and you don't need setup file.

To add event listener go to admin panel -> development -> code event listeners, add listener for event templater_template_post_render. In execute callback put SonnieMail\Listener in first field, templatePostRender in second field. Then assign it to your add-on and click save.

I haven't tested this. There could be errors and whole thing might not even work if XF doesn't call templater_template_post_render event for emails.

edit: instructions are quite messy. Order of things to do: enable development mode, create add-on, create php file, add event listener.
 
Last edited:
Is there a variable replacement for [float_left], [float_right] ... can we get those to parse with this method?
 
Okay... so I suppose I really don't know what I'm doing here... as I am not familiar with how to get the console working. I know how to open a command window, but executing the php code is beyond me. Are there specific instructions for this that I can read?
 
And I suppose I would use the Terminal in our cPanel to do this... as I have used it and gotten it to open asking me for an ID:

204233

Am I on the right track?
 
 
This resource has been removed and is no longer available. The following reason was provided:
This resource has been deleted by XenForo Ltd. in line with our resource housekeeping criteria.
 
Top Bottom