function nodehierarchy_token_values in Node Hierarchy 6
Same name and namespace in other branches
- 5 nodehierarchy_token.inc \nodehierarchy_token_values()
- 6.3 includes/nodehierarchy_token.inc \nodehierarchy_token_values()
- 6.2 includes/nodehierarchy_token.inc \nodehierarchy_token_values()
@file token.module integration functions for nodehierarchy.module
File
- ./
nodehierarchy_token.inc, line 9 - token.module integration functions for nodehierarchy.module
Code
function nodehierarchy_token_values($type, $object = NULL, $options = array()) {
$tokens = array();
if ($type == 'node') {
$node = $object;
if ($parent = node_load($node->parent)) {
$tokens['hierarchyparenttitle'] = check_plain(@$parent->title);
$tokens['hierarchyparenttitle-raw'] = @$parent->title;
$tokens['hierarchyparentnid'] = $node->parent;
}
else {
$tokens['hierarchyparenttitle'] = '';
$tokens['hierarchyparenttitle-raw'] = '';
$tokens['hierarchyparentnid'] = '';
}
$tokens['hierarchytitlepath'] = nodehierarchy_token_get_hierarchytitlepath($node);
$tokens['fullhierarchytitlepath'] = nodehierarchy_token_get_fullhierarchytitlepath($node);
$tokens['hierarchytitlepath-raw'] = nodehierarchy_token_get_hierarchytitlepath($node, TRUE);
$tokens['fullhierarchytitlepath-raw'] = nodehierarchy_token_get_fullhierarchytitlepath($node, TRUE);
$tokens['hierarchypath'] = nodehierarchy_token_get_hierarchypath($node);
$tokens['fullhierarchypath'] = nodehierarchy_token_get_fullhierarchypath($node);
// As of Pathauto 1.5+ or 2.0-alpha3+ in combination with Token 6.15,
// Path and URL tokens are left alone by Pathauto except for tokens with 'path'
// in the name and who's corresponding value is an array of segments.
// This usage can be checked for by the existence $options['pathauto']
// See also 'Using path style tokens' at http://drupal.org/node/936068
if (!empty($options['pathauto'])) {
$tokens['hierarchytitlepath'] = explode("/", $tokens['hierarchytitlepath']);
$tokens['fullhierarchytitlepath'] = explode("/", $tokens['fullhierarchytitlepath']);
$tokens['hierarchytitlepath-raw'] = explode("/", $tokens['hierarchytitlepath-raw']);
$tokens['fullhierarchytitlepath-raw'] = explode("/", $tokens['fullhierarchytitlepath-raw']);
$tokens['hierarchypath'] = explode("/", $tokens['hierarchypath']);
$tokens['fullhierarchypath'] = explode("/", $tokens['fullhierarchypath']);
}
}
return $tokens;
}