panels_tabs.module in Panels Tabs 7.2
Same filename and directory in other branches
Show panel panes in a region as tabs.
File
panels_tabs.moduleView source
<?php
/**
* @file
* Show panel panes in a region as tabs.
*/
/**
* Implements hook_ctools_plugin_directory().
*/
function panels_tabs_ctools_plugin_directory($module, $plugin) {
if ($module == 'panels' && $plugin == 'styles') {
return 'plugins/' . $plugin;
}
}
/**
* Implements hook_panels_pane_content_alter().
*
* Hold the title of the pane for later use (i.e. show it as the tab's title),
* and remove it form the pane itself.
*/
function panels_tabs_panels_pane_content_alter(&$content, $pane, $args, $context, $renderer, $display) {
// Get the regions that should be themed as tabs.
foreach ($display->panel_settings as $key => $values) {
if ($key == 'style_settings') {
continue;
}
if (is_array($values) && !empty($values['style']) && $values['style'] == 'tabs' && $pane->panel == $key || $key === 'style' && $values === 'tabs') {
if (!empty($content->title)) {
// Capture the title.
panels_tabs_pane_titles($display->did, $pane->pid, $content->title);
// Remove it form the pane.
$content->title = '';
}
}
}
}
/**
* Get or set pane title.
*
* @param $did
* Panels display ID.
* @param $pid
* Panels pane ID.
* @param $title
* Optional; Panels pane title to set, or if empty then the function will
* return the captured title based on the display ID and pane ID properties.
*
* @return
* Unsanitized pane title, or NULL if doesn't exist.
*/
function panels_tabs_pane_titles($did = NULL, $pid = NULL, $title = NULL) {
$cache =& drupal_static(__FUNCTION__, array());
if (!isset($title)) {
return isset($cache[$did][$pid]) ? $cache[$did][$pid] : NULL;
}
$cache[$did][$pid] = $title;
return $title;
}
Functions
Name![]() |
Description |
---|---|
panels_tabs_ctools_plugin_directory | Implements hook_ctools_plugin_directory(). |
panels_tabs_panels_pane_content_alter | Implements hook_panels_pane_content_alter(). |
panels_tabs_pane_titles | Get or set pane title. |