Download & Extend

More developer-friendly API (ie: don’t do it all in hook_init())

Project:Menu Breadcrumb
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

I have recently done something like this in one of my own modules:

<?php
   
if ($node->type == 'page' && function_exists('menu_breadcrumb_init')) {
     
// Since menu_breadcrumb does not expose their API, we’ll have to
      // resort monkeypatching the $conf array before re-running their
      // init function.
     
global $conf;
     
$previous_value = variable_get('menu_breadcrumb_determine_menu');

     
$conf['menu_breadcrumb_determine_menu'] = 1;
     
menu_breadcrumb_init();

     
// Revert to the previous value, unsetting if variable_get returned
      // NULL, meaning there was no previous value.
     
if (is_null($previous_value)) {
        unset(
$conf['menu_breadcrumb_determine_menu']);
      }
      else {
       
$conf['menu_breadcrumb_determine_menu'] = $previous_value;
      }
    }
?>

It would be nice if you could disable menu_breadcrumb completely and then only invoke it from your own code, since it might not always be applicable to the whole site.

Comments

#1

One problem might be that menu_set_item doesn't work everywhere (hook_init seems to be the only really reliable place). See #520106: Allow setting the active menu trail for dynamically-generated menu paths.