Skip to main content
Drupal is a registered trademark of Dries Buytaert
EOL Warning: Drupal 11.0 has reached end of life and no longer receives security updates. EOL Warning: Drupal 10.3 has reached end of life and no longer receives security updates. EOL Warning: Drupal 10.2 has reached end of life and no longer receives security updates. EOL Warning: Drupal 10.1 has reached end of life and no longer receives security updates. EOL Warning: Drupal 10.0 has reached end of life and no longer receives security updates. EOL Warning: Drupal 9.5 has reached end of life and no longer receives security updates. EOL Warning: Drupal 9.4 has reached end of life and no longer receives security updates. EOL Warning: Drupal 9.3 has reached end of life and no longer receives security updates. Release: Raven: Sentry Integration 7.5.2 Minor update available for module raven (7.5.2). Usage Milestone: jQuery UI Datepicker Module jquery_ui_datepicker crossed 1,000 active installs.

branch menu

No security coverage Drupal 11 · not 10
View on drupal.org

This module displays Drupal menus as interactive, tree-like graphs using D3.js. It allows you to select a menu from the block configuration and visualizes its structure with angular branches and anti-overlap logic, including hover animations.

A custom Drupal 11 module that renders standard menus as polygonal tree graph using D3.js.

Technical Overview

The Branch Menu module provides a custom block that recursively extracts up to 6 levels of menu links and injects them into a frontend JavaScript environment. The frontend utilizes D3.js to dynamically draw a geometric, downward-flowing tree graph without overlapping nodes.

Features
* **Dynamic Block Configuration:** Select which Drupal menu to render directly from the block layout UI.
* **Polygonal Path Generation:** Overrides standard D3 curves with strict algorithmic rules to create architectural, angular branches (40% to 60% mid-point elbows).
* **Anti-Overlap Logic:** Employs a cascading Y-axis coordinate calculation, ensuring child nodes strictly flow downward and siblings never overlap.
* **Dynamic Typography Placement:** Text anchors automatically flip (left/right) based on the branch direction to prevent intersecting lines.
* **SVG Animations:** Includes hardware-accelerated SVG scaling (`transform-box: fill-box`) and stroke-width transitions on hover.

Architecture

The module is structured as follows:

* `branch_menu.info.yml`: Module declaration and core requirements.
* `branch_menu.libraries.yml`: Dependency management (loads D3.js v7 via CDN and local assets).
* `src/Plugin/Block/BranchMenuBlock.php`: Backend logic to load `MenuLinkTreeInterface`, extract hierarchy, and pass variables to `drupalSettings`.
* `js/branch_menu.js`: Core D3.js logic calculating layout, Bounding Box (viewBox), and SVG paths.
* `js/branch_animations.js`: Event listeners handling non-destructive `mouseenter` and `mouseleave` CSS transitions.
* `css/branch_menu.css`: Base visual styles, crisp-edge rendering, and animation curves.

branch_menu/
├── branch_menu.info.yml
├── branch_menu.libraries.yml
├── branch_menu.module
├── README.md
├── css/
│ └── branch_menu.css
├── js/
│ ├── branch_menu.js
│ └── branch_animations.js
└── src/
└── Plugin/
└── Block/
└── BranchMenuBlock.php

Installation

1. Place the `branch_menu` folder in your project's `web/modules/custom/` directory.
2. Enable the module via Drush (`drush en branch_menu`) or the Extend interface.
3. Navigate to **Structure > Block layout**.
4. Place the **"Branch Menu Graph"** block in your desired region.
5. In the block configuration, select the menu you wish to render.
6. Ensure your selected menu has its parent links set to **"Show as expanded"** to allow deep rendering.

Dependencies

* Drupal Core ^11
* D3.js v7 (Loaded externally via jsDelivr CDN by default)

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
2
Tracked since
Jul 2026
Latest release
1 month ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

Version Type Core Release date
1.0.0 Stable 11 Jul 13, 2026
1.0.x-dev Dev 11 Jul 13, 2026