function nodehierarchy_token_values in Node Hierarchy 6.2
Same name and namespace in other branches
- 5 nodehierarchy_token.inc \nodehierarchy_token_values()
- 6.3 includes/nodehierarchy_token.inc \nodehierarchy_token_values()
- 6 nodehierarchy_token.inc \nodehierarchy_token_values()
Implementation of hook_token_values().
File
- includes/
nodehierarchy_token.inc, line 11 - token.module integration functions for nodehierarchy.module
Code
function nodehierarchy_token_values($type, $object = NULL, $options = array()) {
$tokens = array();
if ($type == 'node') {
$node = $object;
$parents = nodehierarchy_get_node_parent_nids($node->nid);
if ($parent = node_load(@$parents[0])) {
$tokens['hierarchyparenttitle'] = check_plain(@$parent->title);
$tokens['hierarchyparenttitle-raw'] = @$parent->title;
$tokens['hierarchyparentnid'] = $parent->nid;
}
else {
$tokens['hierarchyparenttitle'] = '';
$tokens['hierarchyparenttitle-raw'] = '';
$tokens['hierarchyparentnid'] = '';
}
$tokens['hierarchytitlepath'] = nodehierarchy_token_get_hierarchytitlepath($node->nid);
$tokens['fullhierarchytitlepath'] = nodehierarchy_token_get_fullhierarchytitlepath($node);
$tokens['hierarchytitlepath-raw'] = nodehierarchy_token_get_hierarchytitlepath($node->nid, TRUE);
$tokens['fullhierarchytitlepath-raw'] = nodehierarchy_token_get_fullhierarchytitlepath($node, TRUE);
$tokens['hierarchypath'] = nodehierarchy_token_get_hierarchypath($node->nid);
$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;
}