Check-Menus.com

hook_menu_alter

by Maddison Willms Published 2 years ago Updated 2 years ago
image

hook_menu_alter () is invoked via drupal_alter () as part of menu_router_build () before the menu items (which define all valid Drupal paths) are saved to the {menu_router} table. A Drupal path is the string such as 'node' in example.com/?q=node, or assuming clean URLs, example.com/node. Each path in {menu_router} is unique.

Full Answer

What is hook_menu in Drupal 7?

In Drupal 7 and earlier versions hook_menu has been the Swiss Army knife of hooks. It does a little bit of everything: page paths, menu callbacks, tabs and local tasks, contextual links, access control, arguments and parameters, form callbacks, and on top of all that it even sets up menu items! In my book it’s probably the most-used hook of all.

What is hook_menu used for?

One of the simplest uses of hook_menu is to set up a custom page at a given path. You'd use this for a classic "Hello World" module.

How do I wire up the menu_alter to a class?

To wire up the menu_alter there is also a MODULE.services.yml file with an entry that points to the class that does the work: Many core modules put their RouteSubscriber class in a different location: MODULE/src/EventSubscriber/CLASSNAME.php instead of MODULE/src/Routing/CLASSNAME.php.

image

Hickory Burger 8.95

Thick cut bacon, Sweet Baby Ray’s® BBQ sauce, house made crispy onions, green leaf, tomato, mayo

Mushroom Burger 9.25

Fresh mushrooms and garlic sautéed with chopped bacon, sour cream and chives, melted jack, green leaf, tomato, dijon mayo

California Burger 9.50

Roasted red pepper and caramelized onion, melted jack, avocado, seasoned arugula, tomato, honey dijon, mayo

Turkey Burger 8.75

Fresh free-range ground turkey, melted Swiss, green leaf, tomato, red onion, your choice of cranberry aioli or Thousand Island, on a toasted wheat bun

image
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9