Skip to content

Instantly share code, notes, and snippets.

@henrytran9x
Created September 22, 2015 09:12
Show Gist options
  • Save henrytran9x/475bc9ad08fbe377edc8 to your computer and use it in GitHub Desktop.
Save henrytran9x/475bc9ad08fbe377edc8 to your computer and use it in GitHub Desktop.
This module create style content , allow add class for region panel
name = Mod Panel Style
description = Module support Style for Panel region
dependencies[] = panels
core = 7.x
version = 1.0
<?php
/**
* Implements hook_ctools_plugin_directory().
*/
function mod_panel_style_ctools_plugin_directory($module, $plugin)
{
if($module == 'page_manager' || $module == 'panels')
{
return 'plugins/'.$plugin;
}
}
<?php
drupal_add_css(drupal_get_path('module','mod_panel_style') .'/plugins/styles/mod_panel_style/mod_panel_style.css', array('group' => CSS_DEFAULT, 'every_page' => TRUE)); ?>
<div class="example-region">
<?php print render($content); ?>
<?php //print render($content->content); ?>
</div>
.example-pane .blue {color:blue;}
.example-pane .green {color:green;}
<?php
$plugin = array(
'jv_style' => array(
'title' => t('JV Style'),
'description' => t('Follow add class into panel region'),
'render region' => 'jv_render_region',
'pane settings form' => 'jv_settings_form',
'settings form' => 'jv_settings_form',
'hook theme' => array(
'jv_style_region' => array(
'template' => 'jv-region',
'path' => drupal_get_path('module','mod_panel_style').'/plugins/styles/jv_style',
'variables' => array(
'content' => NULL,
'class' => NULL,
),
),
),
)
);
function theme_jv_render_region($vars) {
$content = '';
foreach ($vars['panes'] as $pane_id => $pane_output) {
$content .= $pane_output;
}
if (empty($content)) {
return;
}
krumo($vars);
return theme('jv_style_region', array('content' => $content));
}
function jv_settings_form($style_settings) {
$form['jv_class'] = array(
'#type' => 'textfield',
'#title' => t('Add Class Region'),
'#description' => t('add class for region output'),
'#default_value' => (isset($style_settings['jv_class'])) ? $style_settings['jv_class'] : ''
);
return $form;
}
<?php
drupal_add_css(drupal_get_path('module','mod_panel_style') .'/plugins/styles/mod_panel_style/mod_panel_style.css', array('group' => CSS_DEFAULT, 'every_page' => TRUE)); ?>
<div class="example-pane">
<?php if (isset($content->title)): ?>
<h2 class="pane-title <?php print (isset($settings['top_color'])) ? $settings['top_color'] : 'blue'; ?>"><?php print $content->title; ?></h2>
<?php endif ?>
<div class="pane-content">
<?php print render($content->content); ?>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment