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..
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | menu_minipanels_panel_alter.patch | 1.42 KB | amorsent |
Comments
Comment #1
amorsent commentedPatch
Comment #2
m.stentaI'm using this patch on a high-traffic production site now... works great! Marking as RTBC... ready to be committed in my opinion!
Comment #3
damienmckennaIt needs a small addition to API.txt.