Adding a minipanel with context inside quicktabs
I use the quicktabs module occasionally to display tabbed content. I recently ran into a situation with a complex user profile that caused me to have to display a minipanel with contexts inside a quicktabs block. There was no easy way that I could find to pass the contexts through the quicktabs block to my minipanel. Because of this, I came up with this solution (be warned, it is a little bit of an ugly workaround).
/** * Implements hook_block(). */ function MYMODULE_block($op = 'list', $delta = 0, $edit = array()) { if ($op == 'list') { $blocks = array(); $blocks[0] = array('info' => t('My Mini Panel'),); return $blocks; } else if ($op == 'view') { switch ($delta) { case 0: $user = menu_get_object('user_uid_optional'); $node = content_profile_load('CONTENT_PROFILE_TYPE', $user->uid); //add contexts to the mini panel ctools_include('context'); $panel_mini = panels_mini_load('MY_MINI_PANEL'); $user_context = new StdClass(); $user_context->type = 'user'; $user_context->data = $user; $node_context = new StdClass(); $node_context->type = 'node'; $node_context->data = $node; $contexts = array($node_context, $user_context); $context = ctools_context_match_required_contexts($panel_mini->requiredcontexts, $contexts); $panel_mini->context = $panel_mini->display->context = ctools_context_load_contexts($panel_mini, FALSE, $context); $block = array( 'subject' => t('My Mini Panel'), 'content' => panels_render_display($panel_mini->display), ); return $block; break; } } }



Discussions
Post new comment