function sheetnode_tokens_alter in Sheetnode 7
Same name and namespace in other branches
- 7.2 sheetnode.module \sheetnode_tokens_alter()
Implements hook_tokens_alter().
File
- ./
sheetnode.module, line 436 - Module file for the sheetnode module.
Code
function sheetnode_tokens_alter(array &$replacements, array $context) {
if ($context['type'] == 'node' && !empty($context['data']['node'])) {
$node = $context['data']['node'];
$tokens = $context['tokens'];
foreach (sheetnode_get_sheetfields($node->type) as $field_name => $field_info) {
if ($sheet_tokens = token_find_with_prefix($tokens, $field_name)) {
// TODO: how to handle multi-valued fields here?
$replacements += token_generate('sheet', $sheet_tokens, array(
'sheet' => $node->{$field_name}[LANGUAGE_NONE][0]['value'],
), $context['options']);
}
}
}
}