-
-
Save annikaC/47c5f2657002ab0e56f7b106c08b49f6 to your computer and use it in GitHub Desktop.
Drupal 7, Panels 3.3+ Pane Style Plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Custom panels. Place in MYMODULE/plugins/styles folder | |
*/ | |
// Plugin register | |
$plugin = array( | |
'title' => t('Accordion'), | |
'description' => t('Make pane or region accordion themed'), | |
'render pane' => 'MYMODULE_accordion_style_render_pane', | |
'pane settings form' => 'MYMODULE_accordion_settings_form', | |
'render region' => 'MYMODULE_accordion_style_render_region', | |
'settings form' => 'MYMODULE_accordion_settings_form', | |
'category' => t('MYMODULE'), | |
); | |
/** | |
* Renders the pane content. | |
*/ | |
function theme_MYMODULE_accordion_style_render_pane($vars) { | |
$content = $vars['content']; | |
if (!empty($content)) { | |
return theme('collapsible_text', ['title' => $settings['accordion_title'], 'body' => $content, 'anchor' => ''); | |
} | |
} | |
/** | |
* Accordion settings form. | |
*/ | |
function MYMODULE_accordion_settings_form($style_settings) { | |
$form = array(); | |
$form['accordion_title'] = array( | |
'#type' => 'text', | |
'#title' => t('Enter accordion title'), | |
'#default_value' => (isset($style_settings['accordion_title'])) ? $style_settings['accordion_title'] : '', | |
); | |
return $form; | |
} | |
/** | |
* Renders the region content. | |
*/ | |
function theme_MYMODULE_accordion_style_render_region($vars) { | |
$settings = $vars['settings']; | |
$panes = $vars['panes']; | |
if (!empty($vars['panes'])) { | |
return theme('collapsible_text', ['title' => $settings['accordion_title'], 'body' => $panes, 'anchor' => ''); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_ctools_plugin_directory(). | |
*/ | |
function MYMODULE_ctools_plugin_directory($module, $plugin) { | |
if ($module === 'panels' || $module === 'ctools' && !empty($plugin)) { | |
return "plugins/{$plugin}"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment