I may be misunderstanding. I was hoping to inject a block of an exposed view filter in my menu so it would look like this;

home | about us | search ___________________ (text box field (from exposed filter)for typing search criteria). I do not see what this did for me that I couldn't do by just adding a new menu item with a url pointing to my block. This appears to be what happened, unless I did something wrong?

Thanks

CommentFileSizeAuthor
#8 menu_inject_bloc_d7_rewrite.patch2.89 KBeme
#5 menu.png17.88 KBeme

Comments

andrew m riley’s picture

Category: support » bug

I'm guessing its a bug (the 7.x branch is still very much in development). The block should be living in the menu, not a link to the block.

IWasBornToWin’s picture

That would be very cool

IWasBornToWin’s picture

This is an inline menu. Wonder if that would matter?

eme’s picture

Works fine for me in D7, BUT it seems that it is may not be taken into account if it is the main menu called by the theme (tested with OMEGA).

OMEGA runs theme_links and not theme_menu_links to output its menu (and it has overrides on the links (omega_links)). It may be the same in other themes.

eme’s picture

StatusFileSize
new17.88 KB

I have worked on this and I may have a suggestion :

We could use the theme_link function instead of the theme_menu_link function.

$theme_registry['link']['function'] = 'menu_inject_block_theme_link';

The principle of changing the link in menu_link_alter seems strange to me, but if we do not see something cleaner, I suggest :

$item['href'] = 'menu_inject_block/' . $module . '/' . $delta;

as we need the module type and delta but no real paths that are for example everywhere via contextual link module. I wrote the theme_link function like this (taking what the module already does) :

function menu_inject_block_theme_link($variables) {
	if ( strpos($variables['path'], 'menu_inject_block/') === 0) {
    $explode = explode('/', $variables['path']);
    $module = $explode[1];
    $delta = $explode[2];
    $block = block_load($module, $delta);
    $block_content = _block_render_blocks(array($block));
    $build = _block_get_renderable_array($block_content);
    $block_rendered = drupal_render($build);
		return $block_rendered;
	} else {	
	  return '<a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . drupal_attributes($variables['options']['attributes']) . '>' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '</a>';
	}
}

Why ?

1. We may see actually the output in the administration menu (I think an global option or per menu or per item would be great as we do not really kwow what we will put into the blocks and it may be too much). See image attached. Some css is required, though to avoid collapsing the drag and drop with contextual link.

2. Any l('thing', 'menu_inject_block/module_id/delta') would take the block so the module may be more extensible and will cleanly work with any menu from theme (tested with omega, but it is sure that any link goes through the l() function).

3. Really interesting (and that is why I digged into the module), we may use it in conjunction with megamenu module (http://drupal.org/project/megamenu) so we can imagine a megamenu containing thanks to your module a view, a search block, a custom block, in one word, anything. And I think that any type of mega menu could leverage this module the same way.

@Adrew M Riley : Please tell me if you think we can go to this direction or not and I may then contribute a clean version of above suggestions.

andrew m riley’s picture

Assigned: Unassigned » andrew m riley

I really like the concept eme. I want to give it a try to see how it would work out. If it does work out, I think this would be great for a 2.x branch.

eme’s picture

Great. Tell me if / how you want me to help out.

eme’s picture

StatusFileSize
new2.89 KB

Here is a patch, but generated with Netbeans so tell me if it does not apply well.

What is the meaning of /% in the hook_menu. What is it required for ?

phantomvish’s picture

Is there a D6 version of this patch that I can test? BTW, I'm trying to do the same thing in D6 and all I get is a menu item with path pointing to "block-system-0". Wonder what I might have missed :-(

phantomvish’s picture

I'm able to see the block in menu when I use garland theme, but I want it in mystique theme.

eme’s picture

As the development of this module seems stopped for now, you can switch to maximenu module.

gratefulsk’s picture

If anyone is coming across this thread I just wanted to point out that there is a module with a stable release that does pretty much the exact functionality. It is Menu Attach Block.

phantomvish’s picture

@celticremark - thanks, but no d6 version of Menu attach block :-(