function nodehierarchy_token_get_hierarchypath in Node Hierarchy 6
Same name and namespace in other branches
- 5 nodehierarchy_token.inc \nodehierarchy_token_get_hierarchypath()
- 6.3 includes/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 86 - 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 "";
}