You are here

function nodehierarchy_pathauto_get_hierarchypath in Node Hierarchy 6

Same name and namespace in other branches
  1. 5 nodehierarchy_pathauto.inc \nodehierarchy_pathauto_get_hierarchypath()
2 calls to nodehierarchy_pathauto_get_hierarchypath()
nodehierarchy_pathauto_get_fullhierarchypath in ./nodehierarchy_pathauto.inc
nodehierarchy_pathauto_get_placeholders in ./nodehierarchy_pathauto.inc
Generate the hierarchy placeholders.

File

./nodehierarchy_pathauto.inc, line 52
pathauto.module v1 integration functions for nodehierarchy.module pathauto v2 uses token for generation makingt his file obsolete

Code

function nodehierarchy_pathauto_get_hierarchypath($node) {
  if ($node) {
    $node = node_load($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}") {
        return $parent_path;
      }
      elseif ($node->parent) {

        // recurse
        return nodehierarchy_pathauto_get_fullhierarchypath($node->parent);
      }
    }
  }
  return "";
}