Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm not it's probably not a good idea to do this for performance reasons, but for the sake of understanding what's going on in token, I'd like to know why the following does not include the CCK fields in mytoken:
function mymodule_token_values($type, $object = NULL, $options = array()) {
$values = array();
switch ($type) {
case 'node':
$node = $object;
$values['mytoken'] = node_view($node);
break;
}
return $values;
}
When I use this token in an email with rules, it does not contain the CCK fields value but only the title of the node. Note this is on new node submission. Inspecting $object, it seems token already partially renders it, which might explain why it cannot be used in node_view?
Comments
Comment #1
Dave ReidYou'd want to look at cck's content.token.inc file to see how they do it:
Keep in mode the $node object is passed by reference, so you should use drupal_clone() before calling it through any view/build type functions.
Comment #3
kenorb CreditAttribution: kenorb commentedAny contributed module which provides this token?
Something similar to node_embed, but which support token?
Comment #4
kenorb CreditAttribution: kenorb commented#181546: Token for body of node
Comment #5
kenorb CreditAttribution: kenorb commentedAny working examples or other solutions?
Comment #6
Dave ReidNot that we know of.