Im using the menu_trail_by_path which does a pretty good job for most of my URL's, however in a custom module I'm setting the breadcrumbs directly (drupal_set_breadcrumb in a page callback). These crumbs get messed up due the menu_trail_by_path module (sort of overwritten I guess =/)

This happens because menu_trail_by_path sets the crumbs using hook_page_delivery_callback_alter which is called after the page callback apparently.

I would like to keep my custom crumbs in the page callback as it has all the required (dynamic) data available.

Hero we go.. how on earth can I disable the page_delivery_callback_alter hook from the menu_trail_by_path module... once? I.e. for the current runtime /request only.


Roland Franssen

1 Answer 1


You could implement hook_module_implements_alter() to avoid a hook implemented by a module is invoked. The problem is that Drupal saves in cache the list of modules implementing a hook, but you can change the list of hooks implemented by modules back to the original one.

function mymodule_implements_alter(&$implementations, $hook) {
  if ($your_condition && ($hook == 'page_delivery_callback_alter')) {
    $old_implementations = &drupal_static(__FUNCTION__, array());
    if (empty($old_implementations)) {
      $old_implementations = array_merge(array(), $implementations);

function mymodule_exit() {
  $old_implementations = &drupal_static('mymodule_implements_alter', array());
  $implementations = &drupal_static('module_implements');

  if (!empty($old_implementations)) {
    $implementations['page_deliver_callback_alter'] = $old_implementations;

This code works only in the case hook_exit() is invoked, which is normally done in drupal_page_footer().

You should be sure mymodule_implements_alter() is executed after the implementations made from other modules, in order to preserve the changes done from other modules.

  • 1
    Oh dear god :-) Commented Jul 19, 2015 at 7:17
  • This is inception!
    – JayKandari
    Commented Oct 11, 2021 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.