0

1. I have two fields in my newsletter content, the normal 'Body' and another called 'The List' (.field-field-thelist). I am trying to print this out in the newsletter but I cannot seem to get it working.

htmlmail-simplenews.tpl.php:

// this doesn't work
<?php print $node->field_field_list[0]['view'] ?>

I don't think I am doing this correctly, but I am basing it from this walkthrough.


2. For some reason when I call the newsletter to print $body (simplenews-newsletter-body.tpl.php), it also prints the $footer (simplenews-newsletter-footer.tpl.php) content ($footer doesn't actually print anything alone).

htmlmail-simplenews.tpl.php:

//Prints body AND footer for some reason, I want to separate these as two variables
<?php echo $body; ?>

The reason #2 confuses me is because there is very clearly 2 variables for each a body and footer in the simplnews.module file. Is there another way I can call these separately?

Note: I am not using Views for this newsletter

1

$node is available within the simplenews templates. htmlmail-simplenews.tpl.php is a generic template that is not simplenews specific.

$body in this context is the mail body, which has been created by combining the simplenews body and footer. Again, within Simplenews, those are separated, but are then simply concatenated together before passed to the htmlmail template.

To get to the node object in there, look at the example templated provided by HTML Mail, which uses $params['context']['node'] and $params['simplenews_source']->getNode() in Drupal 7.

|improve this answer|||||
  • 1
    To figure out why your first print $node.... isn't working, throw in a drupal_set_message('<pre>' . print_r($node, true) . '</pre>'); in the top of the template. That will burp out all of the $node contents for you and you can see what you should be using. If that doesn't work, eg, the message gets lost somewhere instead of the screen, you can use watchdog('my_module','<pre>' . print_r($node, true) . '</pre>'); to write it to the database (assuming you have database logging turned on) and look at it there. – Jimajamma Apr 14 '12 at 1:58
  • Thankyou both for your very helpful answers, i'll test them out when I have a chance tonight and let you know I go! – Matt Rowles Apr 14 '12 at 7:42
  • Not sure why this didn't occur to me at first, but I moved the entire template into the 'simplenews-newsletter-body.tpl.php' file and simply just had the <?php echo $body; ?> in the htmlmail-simplenews.tpl.php. Thanks for the help guys. I'll post the code I used for displaying the extra fields in the emails later also. – Matt Rowles Apr 15 '12 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.