Since the Category module (http://drupal.org/project/category) is having some weird issues with hierarchy creation, I use NH for this task.

A nice feature of Category are the hidden containers that group content but don't show up in the menu/breadcrumb.

In order to achieve the same with NH, just a few lines of code need to be changed:

In modules/nodehierarchy/nodehierarchy_token.inc change the function nodehierarchy_token_get_hierarchypath so it looks like this (changes where it says //added and //bug-fix (see #409728: error in token generation when parent has no url_alias):

function nodehierarchy_token_get_hierarchypath($node) {
  // the hierarchy path is the parent node's full hierarchy path
  // load parent to see if it's a hidden container
  if ($node->parent) {
    $parent_load = node_load($node->parent); //added
    if ($parent_load->category['hidden_cont'] != 1){//added
        // 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);
        }
    }//added
    else {
      // recurse
      return nodehierarchy_token_get_hierarchypath(node_load($node->parent)); //bug-fix
    }
  }
  return "";
}

In nodehierarchy.module, add && $parent->category['hidden_cont'] != 1 to line 770 so it reads:

if (($add_node || $parent->nid != $node->nid) && $item['href'] != '<front>' && $item['href'] != $homepage && $parent->category['hidden_cont'] != 1) {

This is probably a quite rare setup. But maybe it still helps somebody :-D.

Stefan

Comments

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.