Expose tokens
jo1ene - October 17, 2008 - 20:28
| Project: | Node comments |
| Version: | 6.x-1.2-rc2 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
What would it take ($?) to expose tokens for this module so that, for example, the actions or rules module could send a tokenized email to the author of the node target ie. Your page received a comment. I tried it myself, but I'm sure I'm missing something. Maybe it'd be easier for someone who knows how this module works. Basically I tried this in various incarnations:
<?php
/**
* Implementation of hook_token_values.
*/
function node_token_values($type, $object = NULL, $options = array()) {
if ($type == 'node') {
$node = $object;
$tempuid = db_result(db_query("SELECT uid FROM {node} WHERE nid = %d", $node->comment_target_nid));
$target_email = db_result(db_query("SELECT mail FROM {users} WHERE uid = %d", $tempuid));
$values['target-email'] = $target_email;
return $values;
}
}
/**
* Implementation of hook_token_list.
* Seems to work fine.
*/
function node_token_list($type = 'all') {
if ($type == 'node' || $type == 'all') {
$tokens['node']['target-email'] = t("Comment target-node user's email.");
return $tokens;
}
}
?>