Hey there,

i am actualy having a big problem with one of my simplenews templates. I want to print a node reference field in the newsletter with this code:

<?
php print render($build['field_nref_pressestelle'][0]['field_nref_pressesprecher']);
?>

Anything works just fine when i send it as a testmail. But when I try to send it via cron to all subscribers, the reference wont appear ... :-/

Any idea about that?

I attached the full template and a screenshot to my content view configuration to the thread.

Comments

jos_s’s picture

I am experiencing the same problem. This is really a show stopper. It makes the module useless for me.

jos_s’s picture

In reply to myself. I found a cause and solution for my problem, though I really think it is a bug in the module.

I have a custom theme for my HTML emails for simplenews. In that theme there I have a custom template: htmlmail--simplenews.tpl.php

There is also such a template in the website theme, which is however different.

It appears that when sending a test for a newsletter, the template file in custom theme is used (as it should be), but when sending the newsletter with the cron, the template file in the website theme was used (which is wrong!).

Somehow, when sending the newsletter with cron, the system does not use the configured theme for sending e-mails, but the website theme.

Can someone tell me where this happens in the code?

miro_dietiker’s picture

This is really complicated. We have a lot tasks about this topic.
One of the key issues is: #374222: Template files do not work when using admin theme

miro_dietiker’s picture

Also please check the README. The problem is covered there.

berdir’s picture

Category: bug » support
Status: Active » Fixed

Yes, this is extensively documented in the README.txt.

Note that you are using a generic mail template provided by htmlmail.module, so the documented workaround for this won't work because it doesn't integrate with that. I suggest you use our own template simplenews-body.tpl.php, which is a replacement for node.tpl.php in which you have access to the $content render array and it's run through the token replacement). There's also a simplenews-footer.tpl.php, if you want to change that.

jos_s’s picture

Thank you miro_dietiker and Berdir for pointing me to the information. I had missed the line in the README that was about the problem, and I had not yet found issue #374222 yet. This will surely help me solve my problem.

It really is complicated...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.