Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

nested_set

2 sites No security coverage
View on drupal.org

Provides a field type to organize arbitrary entities in a hierarchy according to the Nested set model.

This is conceptually very similar to Entity Reference Hierarchy, but takes a different approach to solve the same problem. In contrast to Entity Reference Hierarchy this stores the position of the entities in the nested set as field values, so that no additional database table is needed. It also does not extend core's Entity Reference field, the only data that is stored are the position values.

The benefit of this is that because it solely builds on functionality provided by Drupal core, it integrates tightly with the Entity/Field system so that having multiple hierarchy fields on a single entity or per-translation hierarchies is possible. It is also possible to gather almost all hierarchy-related information in a single entity query. (Some information, for example finding the direct siblings of an element, is more difficult to the nature of the Nested Set Model and the limitations of the Entity Query API.)

The downside is that inserting an element into the tree or reparenting an existing element - which inherently requires updating many elements in the hierarchy - requires saving a potentially large number of entities. This is a lot slower than the two simple database queries that are required by Entity Reference Hierarchy by many orders of magnitude. Also, because this does not build on the Entity reference field it cannot build upon the existing infrastructure of widgets and formatters.

Features

Currently only the field type and a list builder is provided, so while the field can be added to any entity type it is currently only usable with a custom entity. The field will automatically append an element to the right of the nested set and the list builder allows easily organizing the entities in a hierarchy similar to the interface for taxonomy terms.

Note that currently the updating of the position values is not batched so that it will only work for small hierarchies.

Roadmap

  • Save entities through a batch
  • Make the parent a proper computed property
  • Add a children computed property
  • Provide a widget so that the field will become usable for any entity type
  • Add Views integration

Activity

Total releases
1
First release
Apr 2025
Latest release
1 year ago
Release cadence
Stability
0% stable

Releases

Version Type Release date
1.0.0-alpha2 Pre-release Apr 17, 2025