I have a Zen based theme with a bunch of different tpl files for different content types. I have successfully created a working mini-panel based on a view that I only want to display in one of the content types, and can get the mini panel to output using the Blocks interface. My problem is that the blocks interface is limited in it's ability to place the panel where I would like it to go (above the output of the tags at the bottom of the node), and I am thinking that the best route would be to insert the mini-panel into the output through the .tpl

Is there an easy (or any) way to do this?

Comments

chowdah’s picture

To answer my own question, embedding the mini panel as a block works:

<?php
$block = module_invoke('panels_mini', 'block', 'view', 'name_of_mini_panel');
print $block['content'];
  ?>

The Arguments for the module_invoke are as follows:

  • The name of the Module that created the block
  • The hook you want to invoke - in this case 'block'
  • The operation you want to perform, in this case 'view'
  • The programmatic name of the block
    • You can get the name of the mini panel from the Blocks ui by hovering over the 'configure' link for the mini panel and reading the last part (after the last slash) of the link in the status bar. 'panels_mini' is the name of the module that created the block (info extracted as above - except the module name is what falls between the 2nd to last and last slashes in the url).

aendra’s picture

The following works in Drupal 7:

$block = module_invoke('panels_mini', 'block_view', 'mini_panel_machine_name');
print $block['content'];

Note how arguments 2 and 3 are collapsed into simply "block_view".

Ændrew Rininsland
News Developer and polynerd
http://www.aendrew.com

timmarwick’s picture

Drupal 7 - load and render mini-panel, with context:

  $delta = 'my_mini_panel';
  $panel_mini = panels_mini_load($delta);

  ctools_include('context');
  $context = ctools_context_create('entity:node', $node);
  $contexts = ctools_context_match_required_contexts($panel_mini->requiredcontexts, array($context));
  $panel_mini->context = $panel_mini->display->context =  ctools_context_load_contexts($panel_mini, FALSE, $contexts);
  $panel_mini->display->css_id = panels_mini_get_id($panel_mini->name);
  
  // Here is the markup, to with with whatever you wish.
  $markup = panels_render_display($panel_mini->display);

* Note: first arg for ctools_context_create() is -- $type: The type of context to create; this loads a plugin.
For entities in general, this seems to be 'entity:ENTITY_TYPE'.

plong0’s picture

Thank you!