adding new templates to newsletter module
Hi,
Sorry if this is a simple question. Is there a way of adding more templates to the newsletter module? I only get "product_notification" and "newsletter". I have various subscribers and would like to send out emails using different templates without having to alter the default newsletter template everytime.
Thanks
Christoph
Re: adding new templates to newsletter module
What sort of changes do you mean by "new template" ?
I'm trying to understand the "why" behind your question.
Re: adding new templates to newsletter module
OK, what I am trying to do is send a newsletter out to various groups of subscribers. Those groups should get different types of emails with different layout. The only way I seem to be able to achieve this is by manually altering the (single) newsletter template. What I would like to be able is to have a template for group1, group2 etc and then send them a newsletter based on that template. Does this make it clearer?
Thanks
Christoph
Re: adding new templates to newsletter module
Quote:
Originally Posted by
christoph_lutz
Does this make it clearer?
Not really.
What do you need to change between templates? The only thing in the templates is name/message/copyright/disclaimer ... and the newsletter template also includes an unsubscribe link.
How are you preparing your newsletter content? Would it make sense to put your custom styling etc directly into the HTML of the newsletter?
Or am I missing something about what you're trying to accomplish by using alternate templates?
What specific distinction are you aiming for?
Re: adding new templates to newsletter module
I am preparing the html content outside in a text editor. The problem is that I would like different logos, fundamentally different layout etc. I have experimented with having a "template" that just puts out the html I paste in and nothing else but that means that things like name, copyright, disclaimer etc could not be done easily and if I want those then I'd need to use the template and then I am restricted again to the kind of html framework that comes in the single template...
Christoph
Re: adding new templates to newsletter module
Okay.
How do you currently differentiate between subscriber groups when sending these various newsletters?
Re: adding new templates to newsletter module
i have amended the subscribe to newsletter option where users can tick different categories, so I can select those when sending a newsletter
Christoph
Re: adding new templates to newsletter module
1. edit /includes/functions/functions_email.php
around line 329, find this section. Add the additional code as shown:
Code:
if (!file_exists($template_filename)) {
if (isset($block['EMAIL_TEMPLATE_FILENAME']) && file_exists($template_filename_base . $block['EMAIL_TEMPLATE_FILENAME'] . '.html')) {
$template_filename = $template_filename_base . $block['EMAIL_TEMPLATE_FILENAME'] . '.html';
} elseif (file_exists($template_filename_base . str_replace(array('_extra','_admin'),'',$module) . '.html')) {
2. /admin/includes/modules/newsletter.php
around line 99, find this section. Add the new line, as shown:
Code:
$html_msg['EMAIL_FIRST_NAME'] = $audience->fields['customers_firstname'];
$html_msg['EMAIL_LAST_NAME'] = $audience->fields['customers_lastname'];
$html_msg['EMAIL_MESSAGE_HTML'] = $this->content_html;
$html_msg['EMAIL_TEMPLATE_FILENAME'] = $whatever_filename_you_specify_here;
zen_mail($audience->fields['customers_firstname'] . ' ' . $audience->fields['customers_lastname'], $audience->fields['customers_email_address'], $this->title, $this->content, STORE_NAME, EMAIL_FROM, $html_msg, 'newsletters');
3. Now make whatever additional code edits (to the newsletters.php file) would be required to get the $html_msg['EMAIL_TEMPLATE_FILENAME'] variable to contain the name of the template you want loaded.
The way it's coded above, it'll expect files named like this:
/email/email_template_*******.html
... where ******* is the name you get inserted into the $html_msg['EMAIL_TEMPLATE_FILENAME'] variable.
Since you've made some code edits to allow you to select groups, perhaps you can link a text string with those groups which could be used as the filename piece.
4. repeat #2 & #3 for the product_notifications module file if necessary.
Re: adding new templates to newsletter module
Thanks for your reply and the code and the explanation. I have made the amendmends but don't understand the last step - how do I now compose a message and send it to the right group of people? What do you mean by text string? Would it not be that I should select the template from the drop-down that currently says "newsletter" and "product_notification"?
Thanks
christoph
Re: adding new templates to newsletter module
Quote:
Originally Posted by
christoph_lutz
Thanks for your reply and the code and the explanation. I have made the amendmends but don't understand the last step - how do I now compose a message and send it to the right group of people? What do you mean by text string? Would it not be that I should select the template from the drop-down that currently says "newsletter" and "product_notification"?
That dropdown determines which module to run from the modules/newsletters folder.
If you want to add something to that dropdown and write a new module to go with it, feel free.
I've only given you the steps on how to reference additional templates from within the code.
I have no idea how you've altered things to collect additional newsletter choices, nor do I know how you currently select which audience to send to.
If you use a built-in audience feature from the query_builder tools, then you should be able to match an audience name with a template name so that there are no interface changes required to the newsletter screen. Sorry if that's too much tech talk -- you sounded like you had a handle on programming when you said you altered things to allow additional newsletter choices.