One of the biggest WTF issues I've had with Mini panels is that you can't use Required contexts unless you are using the Mini panel via a Page manager page... which I didn't even know that was the issue until I started digging.

I understand the reason for this, as it's how the Contexts are provided, but it would be easy enough for other modules (custom and contrib) to build up the provided data for the Contexts themselves.

My use case is a Node display, I personally use Display suite, but I have the need for Mini panels for a more complex block of context aware data than the DS Dynamic field is capable of handling (DS Dynamic field only handles a single item), but the Node context can only be provided if I was using Page manager for the Node display.

Simple fix, add a drupal_alter() in the hook_block_view(), so that my own custom module can build the ctools_context object for the node.

Patch in comment #1.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Deciphered’s picture

Status: Active » Needs review
FileSize
642 bytes

Example use:

/**
 * Implements hook_panels_mini_block_contexts_alter().
 */
function HOOK_panels_mini_block_contexts_alter(&$contexts, $panel_mini) {
  foreach ($panel_mini->requiredcontexts as $required) {
    if ($required['name'] == 'entity:node' && arg(0) == 'node') {
      $node = menu_get_object();

      $context = new ctools_context(array('entity:node', 'entity', 'node'));
      $context->data = $node;
      $context->title = $node->title;
      $context->identifier = $required['identifier'];
      $context->argument = $node->nid;
      $context->keyword = $required['keyword'];
      $context->original_argument = $node->nid;
      $context->restrictions['type'][] = 'article';
      $context->plugin = 'entity:node';
      $context->id = 'argument_entity_id:node_1';

      $contexts[ctools_context_id($required, 'requiredcontext')] = $context;
    }
  }
}
realityloop’s picture

Status: Needs review » Reviewed & tested by the community

works as advertised

japerry’s picture

Status: Reviewed & tested by the community » Fixed

More alters are good. Committed

  • japerry committed 6ecb70f on 7.x-3.x authored by Deciphered
    Issue #2172889 by Deciphered: Allow altering of Mini panels contexts
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.