Skip to content

Instantly share code, notes, and snippets.

@ahebrank
Forked from ndeet/MYTHEME.info
Created August 20, 2014 16:02
Show Gist options
  • Save ahebrank/94749a6b3fef806af4a5 to your computer and use it in GitHub Desktop.
Save ahebrank/94749a6b3fef806af4a5 to your computer and use it in GitHub Desktop.
.grey {
background-color: #CCC;
color: black;
}
.yellow {
background-color: yellow;
border: 1px solid red;
}
.pink {
background-color: deeppink;
color: white;
font-size: 120%;
h2 {
text-transform: uppercase;
}
}
<?php
/**
* @file
* Custom panels color presets.
*/
// Plugin registrieren
$plugin = array(
'title' => t('Color preset'),
'description' => t('Set a color preset.'),
// Achtung: render pane wird im Methodenaufruf mit "theme_" prefixed!
'render pane' => 'MYTHEME_color_preset_style_render_pane',
'pane settings form' => 'MYTHEME_color_preset_settings_form',
'category' => t('MYTHEME'),
);
/**
* Renders the pane content.
*/
function theme_MYTHEME_color_preset_style_render_pane($content) {
if (!empty($content)) {
return theme('panels_pane', $content);
}
}
/**
* Color preset settings form.
*/
function MYTHEME_color_preset_settings_form($style_settings) {
$form = array();
$form['preset_color'] = array(
'#type' => 'select',
'#title' => t('Choose color preset'),
'#default_value' => (isset($style_settings['preset_color'])) ? $style_settings['preset_color'] : FALSE,
'#options' => theme_MYTHEME_color_preset_colors(),
);
return $form;
}
/**
* Available color presets.
* @return array
*/
function theme_MYTHEME_color_preset_colors() {
return array(
'grey' => t('Grey'),
'yellow' => t('Yellow'),
'pink' => t('Pink')
// etc.
);
}
; Register Style Plugin directory
plugins[panels][styles] = panels/styles
<?php
/**
* @file
* Preprocess panels color presets.
*/
/**
* Implements hook_preprocess_panels_pane().
*/
function MYTHEME_preprocess_panels_pane(&$variables) {
// Prüfen ob unser Style Plugin aktiv ist.
if(isset($variables['pane']->style['style'])) {
if($variables['pane']->style['style'] === 'color_presets') {
// Setzt die in o.g. theme_MYTHEME_preset_colors definierte Farbe als CSS-Klasse
$variables['attributes_array']['class'][] = $variables['pane']->style['settings']['preset_color'];
}
}
return $variables;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment