Working with hierarchies
Hierarchies are tree structures of content items that can be used to represent everything from product categories, to store locations or site navigation. We've made it easy to work with hierarchies in Dynamic Content and you create and edit hierarchies in the same way that you work with other content, with a few differences.
For a technical introduction to hierarchies, see the Developer guide to hierarchies.
Creating a hierarchyLink copied!
You create a hierarchy the same way as you do any other content item, by choosing "Create content" in the content library and choosing a content type. The only difference is that the content type you choose will be set up to make the content item part of a hierarchy.
In this example, we'll create the hierarchy for a site menu. This is created from a content type called "Site menu item".
The content form opens. You'll notice two differences from a standard content form: the "Hierarchy" label is shown in the top left of the window and the form is divided into two, with an edit text box shown on the left and a normal content form, with all its properties, shown on the right.
The hierarchy is shown as a tree of nodes. The first node we enter is the root node, the one from which all other nodes descend. We'll add the label for this node "Site menu".
The rest of the content item properties can be added as normal. In this simple example we're just including the menu item's name and description. We'll keep the label and the title the same, but they don't have to be.
When you've finished entering all the fields click "Save". For a content item that is part of a hierarchy, the label must be entered and you won't be able to save if you leave the label box empty. The label will be used for the content item name.
The content item is now saved and you can see that it has content item properties just like any other content item. You can now add child items to this node.
Adding an item to a hierarchyLink copied!
To add an item to a hierarchy you add a child to an existing item. We currently have just one node, the "Site menu" root node. Right-clicking any node will show a menu of options, including adding a child node. Choose the "Add child node" menu item.
Give the item a label and fill in its properties. In this case we want to represent the "Womens" area of our site.
When the item is saved, the node labelled "Women" is added as a child to the root node.
We can now add "sibling" items at the same level, or add a child item to the women's section. Clicking the "+" icon to the right of a node is quick way to add children. We'll add "shoes" and "clothing".
Clicking any of the nodes in the hierarchy will open the content item, making it easy for you to traverse the tree.
Adding an existing node to a hierarchyLink copied!
You can add an existing item to a hierarchy, but the item you choose to add cannot already be part of a hierarchy. This means that you can add any item that does not already have a parent.
In this example we've created a hierarchy for the "Electricals" section of a website and we want to add this to the website menu hierarchy.
To add an existing item, open the parent item, then click the ellipsis (...) of the parent node where the new item will be added and select "Add existing node". Here, we want to add the "Electricals" item to the top level of the hierarchy, so we'll choose the root node "Website menu" as its parent.
The content browser opens showing items that can be added to this hierarchy. We'll choose "Electricals".
Note, items that need converting can't be added to a hierarchy. See Converting existing items for use with hierarchies.
All of the descendants of the "Electricals" item are now added to the hierarchy.
Note that if we'd tried to add "Personal care" or "Razors" to the hierarchy we would get an error, because these items are already children of "Electricals".
Renaming a nodeLink copied!
To change a node's label, right click and choose "rename" from the menu.
Enter the new label and click "Ok". The content item name is updated and the node label will change.
Moving a nodeLink copied!
You can drag items from one parent to another within a hierarchy.
In the image shown below, the "Bathroom" node is dragged from the "Home" parent to become a child of "Clearance".
Removing a nodeLink copied!
You can remove unwanted nodes from a hierarchy. Removing a node does not delete the content item that it represents, it just removes the content item from the hierarchy. To remove a node, select it and choose "Remove node" from the menu.
In this example we want to remove "Special offers" from the hierarchy.
When you remove a node, any descendants will be removed as well.
A message is displayed warning you that this node, and all its descendants, will be removed from the hierarchy. Click "Ok" to proceed.
The "Special offer" node has now been removed.
Publishing a hierarchyLink copied!
You publish hierarchies in the same way as any other content item and you can choose to publish a single node, all of the hierarchy or just a part of it.
To publish a node, right click and choose "Publish" from the menu.
You will be asked if you want to publish just the node itself, or all of its descendants. We chose to publish the root node, so if we choose to publish all of its descendants, then the entire hierarchy will be published. For this example we'll choose to publish all descendants.
All of the content items in the hierarchy are now published.
Unpublishing hierarchy nodesLink copied!
You can unpublish the root node of a hierarchy, and any of its individual child nodes. Note, you can only unpublish hierarchy nodes one at a time to help prevent accidentally unpublishing content.
Viewing hierarchy items in the content libraryLink copied!
The content items that are part of a hierarchy can be viewed, filtered and organized in the same way as other content items. In the image below you can see two items: the website menu root node content item and the "Special offers" node that we removed from the hierarchy. The child content items are hidden by default because the "Hierarchy child nodes" setting is turned off. If we turn this option on, then all of the child items will be shown.
All of the content items that are part of the hierarchy are now shown.
Converting existing items for use with hierarchiesLink copied!
If a content item's type is updated from being non-hierarchical to hierarchical after the item was created, the item must be converted before you can add it to a hierarchy.
To convert an item for use with hierarchies, open it from the content library. The item is opened in the content form, overlaid with the "Convert item to hierarchy" dialog. To continue you must convert the item.
When an item is converted it retains all of its field information, and a new version of the item is created.
If you convert a published item you will need to republish it after converting.
Note, if you try to restore to a version of content that was created before an item was converted, you will be prompted to convert the earlier version. See Viewing content revision history
If you update a schema content type with the trait:hierarchy
object, all existing content items for that schema will need to be converted before the items can be added to a hierarchy. See Developer guide - The hierarchy trait.