Node Hierarchy screen shotNode Hierarchy is a module which allows nodes to be children of other nodes creating a tree-like hierarchy of content.

The module offers:

  • Automatic hierarchical urls using pathauto
    (eg: http://example.com/aboutus/history/beginning).
  • Automatic creation of hierarchical menus if desired.
  • Optional Views integration.
  • Optional Node Access integration (REMOVED UNTILL NODE ACCESS IS UPDATED)
  • Installation

    Go to Administer>>Content Management>>Modules and enable the Node Hierarchy module.

    Configuration

    You must then tell the module which node types can be parents and which can be children. To do this you can either:

    • Go to Administer>>Content Management>>Content Types.
      Click "edit" on the types you want modify and check the "Can be parent" and "Can be child" checkboxes.
      -- OR --
    • Go to Administer>>Site Configuration>>Node Hierarchy and check the boxes for the desired types.

    You can also pick a default node for each given type. For example, you can create a page called "Blogs" and have nodes of type "blog" be a child of that page by default.

    Permissions

    You will need to assign the following permissions to the appropriate users:

    • create child nodes: For users who are allowed to create children under existing nodes.
    • edit all node parents: For users who are allowed to change the parent of any node, regardless of authorship.
    • edit own node parents: For users who are allowed to change the parent of nodes which they have authored.
    • reorder children: For users who are allowed to change the order of children on any node.
    • view site outline: For users who are allowed to view the site outline
    • administer hierarchy: For users who are allowed to edit the node hierarchy defaults.

    Using Node Hierarchy

    Creating Hierarchical Content

    To assign a parent to a node, either:

    • Create a new node of a type that whose "Can be child" setting is true or edit an existing node. Expand the Node Hierarchy fieldset and chose a parent from the pulldown.
      -- OR --
    • Navigate to the node you wish to make a parent. Click on the children tab, and click on one of the create links at the bottom of the tab.

    Creating A Menu

    To create a menu for a node, edit the node, expand the Node Hierarchy fieldset and check the "Create Menu" box. Click Submit.

    If the node's parent has a menu item, a new menu will be created for the node under its parent's menu item. The name of the menu item will be the title of the node and its weight will be the node's sort order.

    If you edit the parent of a node or its title, you can recreate an existing menu item by checking "Recreate Menu". This will set the menu item's parent to the new parent and the title to the new title. This is not done automatically on edit, so that you can maintain menu hierarchy separately from node hierarchy if desired.

    If the node does not have a parent or its parent does not have a menu item, the new menu item will be a child of the default menu item set in the Node Hierarchy settings.

    Reordering Content

    Use the green arrow links on the Children tab of the parent node to rearrange child nodes. This will also update the order of any generated menu items as long as they have not been moved from their original location.

    Integration with Other Modules

    Pathauto 1.x

    Node Hierarchy integrates with Pathauto to create hierarchical urls. There are two tokens provided to Pathauto 1.x by Node Hierarchy:
    [hierarchypath]: This is the path of the node's parent.
    [fullhierarchypath]: This is the path to the node including the node's own name. You can use this token on its own to create hierarchical urls for your nodes. This token is the same as [title] for nodes which do not have a parent.

    Token and Pathauto 2.x

    Node Hierarchy integrates with token (and therefore Pathauto 2.x and others). For a description of available tokens see the Pathauto setting screen (or any other token list).

    For Pathauto, the recommended token to use is [fullhierarchypath] as it will reflect any changes you have made to the url of a nodes ancestors. For example, if you have a node called "our history" but you forgot automatically generated urls and create the path alias 'history' for that node, its children will have the automatically generated paths 'history/xxx' instead of 'our-history/xxx'.

    Views

    To enable views integration, turn on the Node Hierarchy Views module. With this module turned on, you will also be able to embed a view of a node's children on that node's page. Node hierarchy integrates with Views to provide the following:
    Arguments
    Parent Node Id - Takes a node id and returns only nodes which are children of that node. Used to provide lists of children for a given node.
    Fields
    Sort Order - The numerical sort order of a child node.
    Actions - A set of actions to manipulate child nodes. Should only be used in views accessible by Administrators.
    Sort Fields
    Sort Order - Use this to sort child nodes by their Node Hierarchy sort order.

    Node Access

    Node Access integration has been removed from Version 6, as the nodeaccess module has not been updated to 6 at the time of this writing.

    Known Issues

    • Not tested for large number (2,000+) of child nodes on a single parent.
    • Conflicts with Book (see this issue for more information: http://drupal.org/node/190456).
    • Settings can break with long content type names.
    • Does not respect revisions - hierarchy settings are revision independent.
    • Not tested with pgsql install

    To Do

    • Improve "Can be child" setting to allow admins to specify which node types can be children of which node types. (e.g. 'chapter' nodes can only be children of 'book' nodes)
    • Drag and drop reordering and parent changing.
    • OPML import and export

Comments

aeronox’s picture

To enable standard Views options such as "exclude" and "label" when listing child nodes, edit views/views_handler_field_nodehierarchy_parent.inc and insert


    $form['label'] = array(
      '#type' => 'textfield',
      '#title' => t('Label'),
      '#default_value' => isset($this->options['label']) ? $this->options['label'] : '',
      '#description' => t('The label for this field that will be displayed to end users if the style requires it.'),
    );
    $form['exclude'] = array(
      '#type' => 'checkbox',
      '#title' => t('Exclude from display'),
      '#default_value' => $this->options['exclude'],
      '#description' => t('Check this box to not display this field, but still load it in the view.  Use this option to not show a grouping field in each record, or when doing advanced theming.'),
    );

within the

options_form(&$form, &$form_state) {

function at line 34.
This might work for other parts of this module too.

I did this because I found that listing "Parent Node: Parent Title" after every entry was ugly.

Gabriel R.’s picture

Really useful. I hope it makes the cut in the next release.

eSparkInfo’s picture

I was searching for similar issue. I got it & solve it at my own with help of it. Now, looks like ok & work well. :) BTW: Thanks...

micheleannj’s picture

Worked perfect!

Really would be a simple and useful addition to the module!

persicsb’s picture

A better solution is to call parent::options_form($form,$form_state) at the first line of the function.

derjochenmeyer’s picture

MacMladen’s picture

How does this module play with i18n and l10n?

Esp. when I need to see and organize nodes within languages.

It is sometimes great problem when you have 3-4 languages and a bunch of pages. Sometimes you assign (by accident) wrong language, sometimes it goes somewhere wrong in hierarchy and sometimes you change your mind and want to move page(s) somewhere else along with translation.

These tasks can be quite time consuming.

_______________
Use Brain. Use Mac.

Mladen Đurić
Koder, Professional Development School

asb’s picture

> How does this module play with i18n and l10n?

Sadly, Node Hierarchy seems not to offer much support for multilanguage sites. Unless you have a language root node, the site outline becomes cluttered with every language-specific node you create. Basically it's pretty much like you'd use D6 for a multilanguage site without using translation.module and i18n.module.

Greetings, -asb

Lukas von Blarer’s picture

i am using the [hierarchytitlepath-raw] token for alias generation. wouldn't this append something to the beginning?

i would really appreciate a feature like the node relationships has got, the translate and reference feature.

joausaga’s picture

When I install the node hierarchy module the blog breadcrumbs dissapear. May be it have some conflict with this type of node. To solve I change the nodehierarchy_set_breadcrumbs function in the nodehierarchy file. The change I made was:

   if ($node->type != "blog") {
      $parent     = $node;
      $homepage   = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
      while (@$parent->nid) {
        $item = menu_get_item("node/". $parent->nid);
        if (($add_node || $parent->nid != $node->nid) && $item['href'] != '<front>' && $item['href'] != $homepage) {
          $breadcrumb[] = l($parent->title, "node/". $parent->nid);
        }
        $parent = node_load($parent->parent);
      }
      $breadcrumb[] = l(t('Home'), '<front>');

      drupal_set_breadcrumb(array_reverse($breadcrumb));
  }

Otherwise I just added "if ($node->type != "blog")".

lewie6’s picture

im using the Node Hierarchy module. D6

im theming a content type in page-[content_type].tpl.php, and i want to 'do something' if the current node does NOT have a parent...basically i want it to only 'do something' if the node is the top parent

so, how do i test if a node does NOT have a parent?

lewie6’s picture

ok i found it!

$node->parent

persicsb’s picture

--- double post --

newmie’s picture

I have a parent page which is associated with my main menu. Its children pages, however, are associated with another menu. Whenever I edit the content page for a child, Node Hierarchy forces the child page into the Main Menu. The only way to seemingly work around this functionality is to remove the child page from ALL menus, which isn't desirable.

Any ideas? Would be most appreciated.

alexbern’s picture

Can't figure out how to set a node to more than one parent. There's a checkbox in content type settings to allow multi parents. No changes when set.
I need this to have the same node in 2/3 different sections. In each, the node shall have the parent's breadrumb displayed.

edit: sorry, wrong documentation. I need this in D7

bpadaria’s picture

@alexbern

Do you get multi parents working with drupal 7 version?

jlballes’s picture

I need to sort alphabetically the node hierarchy parent select, is it possible?
There a patch or code that solves this?

Thanks in advance!

DRSUPPORT’s picture

Hello, I have a custom page template setup and need to render the view within the page.

I managed to get the children to display with the function below:
render($content['nodehierarchy_children'])

However only administrators can see this, I have tried change the permissions etc on the view with no luck.

Can any help me display the node children within a custom page?

Thanks