You are here

function panels_mini_block in Panels 6.2

Same name and namespace in other branches
  1. 5.2 panels_mini/panels_mini.module \panels_mini_block()
  2. 6.3 panels_mini/panels_mini.module \panels_mini_block()

Implementation of hook_block().

Expose qualifying mini panels to Drupal's block system.

File

panels_mini/panels_mini.module, line 33
panels_mini.module

Code

function panels_mini_block($op = 'list', $delta = 0, $edit = array()) {
  if ($op == 'list') {
    $blocks = array();
    $minis = panels_mini_load_all();
    foreach ($minis as $panel_mini) {
      if (empty($mini->disabled) && empty($mini->requiredcontext)) {
        $blocks[$panel_mini->pid] = array(
          'info' => t('Mini panel: "@title"', array(
            '@title' => $panel_mini->title,
          )),
        );
      }
    }
    return $blocks;
  }
  elseif ($op == 'view') {
    $panel_mini = panels_mini_load($delta);
    panels_load_include('plugins');
    $panel_mini->context = $panel_mini->display->context = panels_context_load_contexts($panel_mini);
    $panel_mini->display->css_id = panels_mini_get_id($panel_mini->name);
    $block = array(
      'subject' => $panel_mini->title,
      'content' => panels_render_display($panel_mini->display),
    );
    return $block;
  }
}