Okay, then one approach could be to use the query_name value from the query-builder data (ie: the audiences list) to determine which template to use.
1. Rename your special queries like this:
Code:
Subscriber Group: Bleeding Edge Racers
or
Subscriber Group: All Stars ~ Heavy Hitters
2. Create corresponding email template files.
The email templates for the example names above would be:
Code:
/email/email_template_bleedingedgerac.html
/email/email_template_allstars.html
Explanation:
The template names will be built from the query_name (audience names) starting with 'Subscriber Group: ' followed by up to 15 chars for the template name (or until a ~ is found).
Converted to lower-case letters to find the template filename.
If a filename matching the pattern isn't found, the module name will be used instead.
3. Make the following code edits to the admin/includes/newsletters/newsletter.php:
Code:
function send($newsletter_id) {
global $db;
// Look for audience names starting with 'Subscriber Group: ' and accept up to 15 chars for template name (takes name up to ~ or if no ~ then 15 max chars)
$my_template_name = str_replace('Subscriber Group: ', '', $this->query_name);
$my_template_name = preg_replace('/^[0-9a-zA-Z_~]/', '', $my_template_name);
$pos = strpos($my_template_name, '~');
$my_template_name = strtolower(substr($my_template_name, 0, ($pos > 0 && $pos < 15 ? $pos : 15) ));
$audience_select = get_audience_sql_query($this->query_name, 'newsletters');
$audience = $db->Execute($audience_select['query_string']);
$records = $audience->RecordCount();
if ($records==0) return 0;
$i=0;
while (!$audience->EOF) {
$i++;
$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'] = $my_template_name;
This all requires that you implement the functions_email changes I mentioned earlier.
Bookmarks