Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Nested Set

1 sites No security coverage
View on drupal.org

This module provides a field type to organize entities into a hierarchy using the Nested Set model. It stores the hierarchy information directly within entity fields, integrating seamlessly with Drupal's entity and field system. This allows for multiple hierarchies per entity and per translation, but can be slower for operations like reparenting compared to other methods.

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

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Apr 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
1.0.0-alpha2 Pre-release 10–11 Apr 17, 2025