This Themer's Path to a Pane

10 Oct in code, drupal, theme
A Themer's Solution....

I have in my theme a directory called plugins.
in there I have layouts and styles
in styles I have a folder called thintop
and... in there I have 2 files (tho I have commented out the template file in favor of this fancy rendering which gives me admin links and extra stuff in my pane...
thintop.inc and THEME-NAME-thintop.tpl.php
(based on http://drupal.org/node/495654)
good info at http://drupal.org/node/427192

The .inc looks like this
// ---------------------------------------------------------------------------
// Panels hooks.

/**
* Implementation of hook_panels_style_info().
*/

function THEME_NAME_thintop_panels_styles() {
  return array(
    'thintop' => array(
      'title' => t('Thin Top'),
      'description' => t('Thin Top'),
      'render panel' => 'THEME_NAME_thintop_style_render_panel',
      'render pane' => 'THEME_NAME_thintop_style_render_pane',
      'settings form' => 'THEME_NAME_thintop_style_settings_form',
      'hook theme' => array(
        'THEME_NAME_thintop_box' => array(
          'arguments' => array('content' => NULL),
          'path' => panels_get_path('plugins/styles/thintop'),
          'template' => 'genesis-aii-thintop-box',
        ),
      ),
    ),
  );
}

// ---------------------------------------------------------------------------
// Panels style plugin callbacks.

function theme_THEME_NAME_thintop_style_render_pane($content, $pane, $display) {
  if (!empty($content->content)) {
    $idstr = $classstr = '';
    if (!empty($content->css_id)) {
      $idstr = ' id="' . $content->css_id . '"';
    }
    if (!empty($content->css_class)) {
      $classstr = ' ' . $content->css_class;
    }

    $output = "<div class=\"thintop panel-pane$classstr\"$idstr>\n";
    if (user_access('view pane admin links') && !empty($content->admin_links)) {
      $output .= "<div class=\"admin-links panel-hide\">" . theme('links', $content->admin_links) . "</div>\n";
    }
    if (!empty($content->title)) {
      // !Changed H2 tag to an H1 tag
      $output .= "<h3 class=\"pane-title\">$content->title</h3>\n";
    }

    if (!empty($content->feeds)) {
      $output .= "<div class=\"feed\">" . implode(' ', $content->feeds) . "</div>\n";
    }

    $output .= "<div class=\"pane-content\">$content->content</div>\n";

    if (!empty($content->links)) {
      $output .= "<div class=\"links\">" . theme('links', $content->links) . "</div>\n";
    }


    if (!empty($content->more)) {
      if (empty($content->more['title'])) {
        $content->more['title'] = t('more');
      }
      $output .= "<div class=\"more-link\">" . l($content->more['title'], $content->more['href']) . "</div>\n";
    }

    $output .= "</div>\n";
    return $output;
  }
}



when I was using a template the $output was
  $output .= '<h3 class="pane-title-thintop">';
  $output .= $content->title;
  $output .= '</h3>';
  $output .= $content->content;
  $output = theme('THEME_NAME_thintop_box', $output);
  return $output;



and the tpl.php is pretty basic
<div class="panel-pane thintop">
<?php print $content; ?>
</div>


IMPORTANT!!!



Add to your .info file in your theme!!


;----------// Plugin Panels
plugins[panels][layouts] = plugins/layouts
plugins[panels][styles] = plugins/styles



remember to clear the theme registry... or you'll probably get nothin'

Comments

Post new comment