Hello.
First, I got this working but I had to change the implementation. I was looking for something like this and stumbled upon this module. People pointed out in their issues that this module has several problems, the most important resides in the implementation approach that contradicts "themeability". To alter the theme registry and to attach a theme_menu_link function inside a module breaks things in many ways.
If you want to make this module operative I would suggest that you:
1. Implement requisites and check if the current theme implements a function to handle theme_menu_link using global $theme and function_exists. (Don't forget about base themes, you have to check with drupal_find_base_themes as well.) If a theme function exists, the module should inform that this module requires to adapt the YOURTHEME_menu_link function in template.php. If it doesn't exist than you may modify the theme registry and overwrite the built-in theme_menu_link function call with the module function call.
If YOURTHEME_menu_link exists, the module should inform that the YOURTHEME_menu_link function needs to be adapted to render the desired blocks correctly.
2. Rendering of the block needs to take place inside YOURTHEME_menu_link (or menu_inject_block_theme_menu_link) instead of in menu_inject_block_translated_menu_link_alter. Rendering in hook_translated_menu_link_alter breaks things and causes white screens due to overflows. In menu_inject_block_translated_menu_link_alter you should configure what needs to be rendered this way: $item['localized_options']['#block_to_render'] = array( 'module' => $module, 'delta' => $delta);
3. An example implementation in YOURTHEME_menu_link as well as for the internal menu_inject_block_theme_menu_link looks like this:
if (isset($element['#original_link']) && isset($element['#localized_options']) && isset($element['#localized_options']['#block_to_render']) && drupal_match_path($element['#original_link']['link_path'], "\n/*")) {
$module = $element['#localized_options']['#block_to_render']['module'];
$delta = $element['#localized_options']['#block_to_render']['delta'];
$block = block_load($module, $delta);
$render_array = _block_get_renderable_array(_block_render_blocks(array($block)));
$output = '' . render($render_array) . '';
}
This implementation approach offers several advantages: the implementation maintains themeability and adaptations won't be lost during module updates. Moving the render out of the menu_inject_block_translated_menu_link_alter fixes the show stopper bug present in the current developer version.
Regards.
uh
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | menu_inject_block.zip | 6.94 KB | saveva |
| #6 | module-v2-2826648-6.patch | 17.83 KB | saveva |
| #4 | module-revision-2826648-1.patch | 24.83 KB | saveva |
Comments
Comment #2
saveva commentedComment #3
saveva commentedComment #4
saveva commentedComment #5
saveva commentedComment #6
saveva commentedHi Andrew.
Here's an updated patch with correct formatting. I've attached as well a zip file which makes it easier to follow the code if you don't want to apply the patch without getting the complete image of the code.
Regards.
uh