function nodehierarchy_token_get_hierarchypath in Node Hierarchy 5
Same name and namespace in other branches
- 6.3 includes/nodehierarchy_token.inc \nodehierarchy_token_get_hierarchypath()
- 6 nodehierarchy_token.inc \nodehierarchy_token_get_hierarchypath()
- 6.2 includes/nodehierarchy_token.inc \nodehierarchy_token_get_hierarchypath()
2 calls to nodehierarchy_token_get_hierarchypath()
- nodehierarchy_token_get_fullhierarchypath in ./
nodehierarchy_token.inc - nodehierarchy_token_values in ./
nodehierarchy_token.inc - @file token.module integration functions for nodehierarchy.module
File
- ./
nodehierarchy_token.inc, line 71 - token.module integration functions for nodehierarchy.module
Code
function nodehierarchy_token_get_hierarchypath($node) {
// The hierarchy path is the parent node's full hierarchy path.
if ($node->parent) {
// If the parent already has an alias (generated or entered) use that.
$parent_path = drupal_get_path_alias("node/{$node->parent}");
if ($parent_path != "node/{$node->parent}") {
// Replace the separator with a space, so that pathauto replaces it with the separator again.
// A little hacky but prevents the separator from being stripped.
return str_replace(variable_get('pathauto_separator', '-'), " ", $parent_path);
}
else {
// Recurse.
return nodehierarchy_token_get_fullhierarchypath(node_load($node->parent));
}
}
return "";
}