Mini panels utilizes ctools' powerful context system. The motivation for this issue is to allow a singe mini panel definition to serve multiple menu items, with the menu item passed in as a context.

In a broader sense, I would like to allow modules a chance to alter the panel before it gets rendered.

My suggestion calls an alter hook durring _menu_minipanels_render_panel. It also passes the $mlid to allow modules to utilize this information.

An example implementation of the alter hook would look something like this:

/**
 * Implementation of hook_menus_menu_minipanel_panel_alter().
 */
function my_module_menu_minipanel_panel_alter($panel, $mlid) {
  if (!empty($mlid)) {
    // Add Menu link id context for use by mini panel
    $context = new ctools_context('string');
    $context->plugin = 'string';
    $context->data = $mlid;
    $context->title = 'Menu Link';
    $context->identifier = 'Menu Link';
    $context->keyword = 'mlid';
    $panel->context['requiredcontext_string_1'] = $context;
    $panel->display->context['requiredcontext_string_1'] = &$panel->context['requiredcontext_string_1'];
  }
}

The above example adds the mlid as a simple string context. This can then be used in the panel definition to customize the panel content for each menu link.

Patch to follow..

CommentFileSizeAuthor
#1 menu_minipanels_panel_alter.patch1.42 KBamorsent

Comments

amorsent’s picture

StatusFileSize
new1.42 KB

Patch

m.stenta’s picture

Status: Active » Reviewed & tested by the community

I'm using this patch on a high-traffic production site now... works great! Marking as RTBC... ready to be committed in my opinion!

damienmckenna’s picture

Version: 6.x-1.4 » 6.x-1.x-dev
Issue summary: View changes
Status: Reviewed & tested by the community » Needs work

It needs a small addition to API.txt.