Disable 3rdparty hook from custom module once 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.

Thanks!

Roland Franssen
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(&amp;$implementations, $hook) {
  if ($your_condition &amp;&amp; ($hook == 'page_delivery_callback_alter')) {
    $old_implementations = &amp;drupal_static(__FUNCTION__, array());
    if (empty($old_implementations)) {
      $old_implementations = array_merge(array(), $implementations);
      unset($implementations['menu_trail_by_path']);
    }
  }
}

function mymodule_exit() {
  $old_implementations = &amp;drupal_static('mymodule_implements_alter', array());
  $implementations = &amp;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.