Menu Link Weight
Replaces the standard numeric weight dropdown for menu links with an intuitive tabledrag widget, allowing content editors to visually reorder menu items.
menu_link_weight
Overview
The Menu Link Weight module provides a user-friendly alternative to the standard numeric weight dropdown widget for menu links in Drupal. Instead of requiring users to understand and manually set weight values from -50 to 50, this module presents a tabledrag interface that displays sibling menu links in their current order.
When editing a node or menu link, users can simply drag and drop menu items to reorder them relative to their siblings. The module dynamically updates via AJAX when the parent menu is changed, showing all sibling links under the selected parent. For environments without JavaScript, a graceful fallback button is provided.
Upon form submission, the module recalculates weights sequentially from -50 upward for all affected sibling links, ensuring proper ordering. This approach makes menu organization intuitive for content editors who no longer need to understand the underlying weight system.
Features
- Replaces numeric weight dropdown with visual tabledrag interface for menu link ordering
- AJAX-powered dynamic updates when changing parent menu selection
- Drag-and-drop reordering of sibling menu links directly from node edit and menu link edit forms
- Graceful degradation with a fallback button for non-JavaScript environments
- Automatic weight recalculation from -50 to 50 upon form submission
- Optional integration with Client-side Hierarchical Select (CSHS) module for enhanced parent selection
- Compatibility with Menu Admin Per Menu module for per-menu permission control
- Concurrent edit detection to prevent users from overwriting each other's changes
- Direct link to the menu administration page from the tabledrag widget for quick access
- Real-time title synchronization in the tabledrag list as users type the menu link title
Use Cases
Content editor reordering menu items
A content editor is creating a new page and wants it to appear between two existing menu items. Instead of guessing weight values, they enable the menu link checkbox, see a visual list of sibling items, and drag their new page to the desired position. The module handles weight calculation automatically.
Reorganizing menu structure from node edit form
When editing a node, a site administrator notices the menu needs reorganization. Using the tabledrag widget, they can reorder not just the current node's menu link but all sibling links, then save the node to apply all changes at once.
Managing menus without numeric weight knowledge
Content teams unfamiliar with Drupal's -50 to 50 weight system can intuitively manage menu ordering using drag-and-drop, reducing training time and preventing ordering mistakes.
Hierarchical menu management with CSHS
For sites with deep menu hierarchies, administrators can enable CSHS integration to get a cascading dropdown interface for parent selection, making it easier to navigate and select the correct parent menu item.
Tips
- The module recalculates all sibling weights from -50 upward when saving, so don't be surprised if weight values change after saving
- You can click the menu name link in the widget description to jump directly to the full menu administration page
- The widget shows truncated titles (30 characters) for readability; hover over links to see full titles
- New menu links are placed at the top of the sibling list by default; drag them to the desired position before saving
Technical Details
Admin Pages 1
/admin/config/user-interface/menu-link-weight
Configure the parent menu link selector widget used by the Menu Link Weight module. By default, Drupal's standard select dropdown is used, but you can optionally switch to Client-side Hierarchical Select (CSHS) for a more intuitive hierarchical menu selection experience.
Hooks 4
hook_form_node_form_alter
Alters node forms to replace the weight dropdown with a tabledrag widget for menu link ordering. Adds the tabledrag table, hidden db_weights fields for concurrent edit detection, and AJAX callback for parent changes.
hook_form_menu_form_alter
Alters the menu overview form to add anchor tags (HTML IDs) to each menu link row, enabling direct linking from the node form to specific menu items.
hook_form_menu_link_content_form_alter
Alters menu link content entity forms to add the tabledrag widget for reordering sibling links.
hook_form_menu_link_edit_alter
Alters the default menu link edit form (for system-provided links) to add the tabledrag widget.
Troubleshooting 4
Ensure the user has the 'Administer menu' permission or, if using Menu Admin Per Menu, has been granted access to the relevant menus.
The module detects concurrent edits. If you see an error about weights being changed by another user, reload the form to get the latest weights before making changes.
The Client-side Hierarchical Select module must be installed and enabled before you can use this option. Install it via Composer: composer require drupal/cshs
This is the graceful degradation fallback. Check browser console for JavaScript errors. The tabledrag should work when JavaScript is enabled and functioning.