views:

58

answers:

1

I am using the Rules module to send an email. I need to include a CCK field from my node in the email. The rules module provide a $node object. How do I get from this object to my field so I can output it in the email?

A: 

You can debug it by dumping the node object like so:

var_dump($node);

Or (my preference) you can use the dBug.php script from http://dbug.ospinto.com/ include that script and do

new dbug($node);

It will make the dump easier to read.

Anyway, your node object will have the CCK fields in it marked as field_(name). So if you had a CCK field called Telephone, it would be in the node object as field_telephone with its own properties.

If these fields are missing, the node may not be fully loaded. I've seen that happen. If so, you can simply do:

$full_node = node_load($node->nid);
var_dump($full_node);

That would have a fully loaded node object. Then just point to the correct field in your email script/tpl, however you are doing it, and if there is a value it will be sent.

Kevin

related questions