Jump to content

Hook actionEmailAddBeforeContent


Recommended Posts

Hi all folks !

 

I am currently developing some module, and I would need to override some default mail template.

 

Do someone have an idea how "actionEmailAddBeforeContent" is working ? It is supposed to  change or amend template_html & template_txt before your email template is loaded.

 

I would kie to change template name and template path, and despite several try, I am unable to make It work properly.

 

Some helps would be greatly appreciate !!

 

Jeff

 

Link to comment
Share on other sites

What are you doing in the hook exactly? You should be able to amend the html by reference
 

            Hook::exec('actionEmailAddBeforeContent', array(
                'template' => $template,
                'template_html' => &$template_html,
                'template_txt' => &$template_txt,
                'id_lang' => (int)$id_lang
            ), null, true);
Link to comment
Share on other sites

 $template_html = '';
 $template_txt = '';
            Hook::exec('actionEmailAddBeforeContent', array(
                'template' => $template,
                'template_html' => &$template_html,
                'template_txt' => &$template_txt,
                'id_lang' => (int)$id_lang
            ), null, true);

$template_html .= Tools::file_get_contents($template_path.$iso_template.'.html');

etc..

 

What I would need in fact would be to override at this point $template_path and $iso_template.

 

Not sure that's possible, anyway the exec function last argument is true, so that's supposed that there is an $array_return, what I would like to understand, is what is this $array_return and how to manage It ?

 

I didn't succeed to find any documentation anywhere about it. Some clarification would be great full !

Link to comment
Share on other sites

I eventually succeed in doing what I wanted... Something anyway remain totally obscure for me...

I switch to the second hook of the class Mail :

 

 Hook::exec('actionEmailAddAfterContent', array(
                'template' => $template,
                'template_html' => &$template_html,
                'template_txt' => &$template_txt,
                'id_lang' => (int)$id_lang
            ), null, true);
Yet, like this, this hook doesn't have any sense, so I just add 
$hook =  Hook::exec('actionEmailAddAfterContent', array(
                'template' => $template,
                'template_html' => &$template_html,
                'template_txt' => &$template_txt,
                'id_lang' => (int)$id_lang
            ), null, true);
and of course, at this time, I can amend what I want by using array_shift($hook)
 
That also means that I need to override the complete function send in the override directory, and I try desperately to avoid any override.
So I remain a little bit frustrated, and also if an expert could explain me what the sense of an kook like this, and also how to exploits an Hook who is supposed to manage a return information, without an initial variable declaration ?
 
I would appreciate !
 
Thanks in advance.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...