I love that Simplenews exists - and that it works with charm!
Ive been trying to use Simplenews with Mime Mail to be able to set up different html Newsletters on one site. When trying to theme each newsletter differently and then have to use the template files for both Simplenews and Mime Mail I found that Mime Mail at first didnt get any $mailkey variable from Simplenews.
I found the issue in the queue that solves that problem, ie #324815: Pass $mailkey to Mime Mail, and I implemented the change manually (sending the $message['id'] variable from Simplenews to Mime Mail).
However, it turns out that the id is "simplenews-node ". I had thought it would be the term ID for the newsletter in question - as with regular Simplenews templates?
So, I changed the variable sent to Mime Mail:
<?php
$message['result'] = mimemail(
$message['from'],
$to,
$message['subject'],
$message['body'],
$plain,
$message['headers'],
$plain ? $message['body'] : simplenews_html_to_text($message['body'], TRUE),
isset($message['params']['context']['node']->files) ? $message['params']['context']['node']->files : array(),
$message['id'].'-'.$node->simplenews['tid']
);
?>
$mailkey BEFORE my alteration:
mail-simplenews-node
$mailkey AFTER my alteration:
mail-simplenews-node-[tid]
Im not saying this is the correct way to handle it - I just want the term ID to be passed to Mime Mail for easy templating.
Comments
Comment #1
Agogo CreditAttribution: Agogo commentedAnd for anyone trying to name a template and having trouble - this is the way to name it with above code used:
mimemail-message--simplenews-node-[tid].tpl.php
Comment #2
miro_dietikerI don't know any other module that passes IDs into mailkey.
Pity mimemail doesn't support any context object to pass (which is missing for many drupal modules)
The intention of mailkey is primarily to know that the the origin was simplenews. Not much more.
Why do you need that alter context? Why don't you use the theming before?
Comment #3
Agogo CreditAttribution: Agogo commentedCan you elaborate those questions?
Comment #4
miro_dietikerI don't know exact limitations of 6.x-1.x features...
However note that in 6.x-2.x all .tpl.php have the full node object available.
Please help us complete 2.x. Note that 1.x is feature frozen - bugfixes only.
Comment #5
Agogo CreditAttribution: Agogo commentedAh, thanks, well I need to be able to seperate the Mime Mail templates - not the Simplenews templates. Im guessing that full $node array isnt sent to Mime Mail?
Noted about 2.x. Mostly posted to make other users aware if they needed the same functionality as me.
Comment #6
miro_dietikerWhile i agree this was originally somewhat a bug, this is now a feature request.
Comment #7
alexkb CreditAttribution: alexkb commentedAgogo, thanks for sharing this.
Another sorta annoying thing is that when you do the newsletter test emails, $message['id'] is changed to "test" instead of "node" - which results in the default template file getting used. So my preference is to just return the tid, like so.
Cheers.
Comment #8
alexkb CreditAttribution: alexkb commentedI should add that v2.x of simplenews is still an alpha (it was -dev when this thread was opened) - which implies its not really ready for production sites yet.
Comment #9
alexkessler CreditAttribution: alexkessler commentedThx Agogo & alexkb!
Exactly what i needed...
Comment #10
GBain22 CreditAttribution: GBain22 commentedStill having problems:
Hello, I wish to use different mimemail templates for different newsletters that I have, currently I have:
mywebsite.com/admin/content/simplenews/types/edit/2
So I am using the tid of 2 from the above url - my simplemail.mail.inc looks like this:
And my file is called: mimemail-message--simplenews-node-2.tpl.php
I have tried putting this in my normal theme "Clean", in my admin theme "Rubik" and also in the Mimemail module "sites/all/modules/mimemail" but it only ever uses the mimemail-message.tpl.php (it uses this from the Clean theme, or just from the module directory itself).
Is there any place I am going wrong here?
My versions are: Mimemail 6.x-1.0 and simplenews 6.x-2.0-alpha3
Comment #11
Agogo CreditAttribution: Agogo commentedInstead of using:
$message['id'].'-'.$node->simplenews['tid']
Try:
$message['id'].'_'.$node->simplenews['tid']
Should work