With the advent of nodes that don't necessarily have a body field, and especially with drupal_render(), I am curious what is now the best approach to send a node's rendered content (albeit converted from HTML to plain text) in an email.
E.g. for a rule triggered on the creation of a new node, how to send that node's content to some address in a "Send Email" action?
Putting this in the action's message field:
<?php
print drupal_render_children(node_view($node));
?>
... results in an email sent out looking like this, missing line breaks between fields:
Field 1: Field 1 ValueField 2: Field 2 ValueField 3: Field 3 ValueField 4: Field 4 ValueField
5: Field 5 ValueField 6: Field 6 Value
Is there a better way to send a node's content in the body of email as part of a "Send Email" action?
Comments
Comment #1
westbywest CreditAttribution: westbywest commentedHere is the work-around I was able to find to the missing line-break problem.
Seems that the node fields are enclosed in <div> tags. At some point, the core function drupal_html_to_text() is being called on the email body, and this function is not smart enough to insert line breaks in place of each <div></div> pair it strips. The code above just inserts <br/> tags to force drupal_html_to_text() into adding line breaks.
Comment #2
mitchell CreditAttribution: mitchell commentedPlease work on solving this, and then create a page in the documentation handbook.
Comment #3
bbruda CreditAttribution: bbruda commentedIf you got Strint Warning error then change for:
Comment #3.0
bbruda CreditAttribution: bbruda commentedtypo
Comment #4
TR CreditAttribution: TR commented