Skip to content

fourkitchens/node_in_menu

Repository files navigation

Node in Menu (node_in_menu)

Provides a Views filter that filters nodes by whether they are referenced in a specific menu.

Overview

This module adds a Views filter called "In menu" to node-based Views. It lets you restrict results to nodes that have a menu link in a chosen menu, matching either direct node links or links that point to the node via a path alias.

Requirements

  • Drupal core: 10.x or 11.x
  • Core modules: views, menu_link_content, path

Installation

  • Enable the module like any other Drupal module.
    • UI: Extend → search for "Node in Menu" and enable it.
    • Drush: drush en node_in_menu -y

Usage

  1. Create or edit a View of type Content.
  2. In the View, under Filter criteria, click Add and search for In menu.
  3. Add the filter and select the target Menu from the dropdown.
  4. Save the View. The results will now only include nodes that have an enabled menu link in the selected menu.

How it works

  • Registers a Views filter plugin @ViewsFilter("node_in_menu") and exposes it on the node_field_data base table.
  • The filter adds an EXISTS subquery against menu_link_content_data, also checking path_alias so links via aliases are matched.

Compatibility notes

  • Works on node-based Views (base table node/node_field_data).
  • Expects the core menu_link_content and path modules to be enabled.

Limitations

  • Only checks for enabled menu links in the chosen menu.
  • Does not currently support filtering by multiple menus at once.

Development

  • Code is PSR-4 under src/ and the Views integration lives in node_in_menu.views.inc.
  • Run drush cr after enabling or making code changes to rebuild caches.

License

GPL-2.0-or-later. See LICENSE.txt.

About

Provides a views filter that filters nodes by whether they are referenced in a menu

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages