开发者

Drupal get a CKK field from a node object

开发者_如何学Python

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜