It would be a nice feature if somewhere in the panels settings you could specify what the default style would be when adding new panes.

For instance we are creating a website right now that almost all of the panes are use the "System Block" style to match the styling normal system blocks get. This means that each time a pane is added you have to remember to go in to the style for that pane and choose the "System Block" style which is a bit of a pain.

You also cannot choose styles in the IPE which means we cant really use the IPE. Each new pane you would add through it you would then have to go into the panel content and manually change the pane style, which makes the IPE not so useful for adding panes, though it is handy for editing them quickly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

Yeah, I can see this being a useful option.

kant’s picture

Me too. Subscribing...

heylookalive’s picture

Subscribing!

z1pzap’s picture

Subscribing!

Johan den Hollander’s picture

Subscribing. This would be a nice feature to have. There are quite a few people who can create new content in my sites panes. They need to be instructed now to use the right style.

A possible workaround could be to switch the default style to the desired style although I did not try that myself.

karljohann’s picture

Has there been any progress on this?

clashar’s picture

Letharion’s picture

Assigned: Unassigned » merlinofchaos
Status: Active » Needs review
FileSize
1.56 KB

@merlinofchaos
The patch is in no way ready, but I would appreciate if you could take a look at it.
Problems:
1) Where should the select box be?
2) Where should I be setting the default? I can't seem to reach the configuration from the function where I do it now?
3) Other things?

codewatson’s picture

I imagine that the place to have the configuration would be on the /admin/build/panels/settings page or the sub pages of that so that each type (page, mini, panel node) could have it's own custom setting?

Bugger if i can find where those forms are built, panels and ctools seem so integrated its hard to tell which one controls what, had to stop looking before my head exploded.

merlinofchaos is there any direction you can give us for figuring this out?

Old Account’s picture

This would be an awesome feature.

FilipNest’s picture

Has anyone had any luck with this since #8?

I've made two custom style plugins, one with a select list for choosing from a list of CSS classes and another with just a CSS class text-field input and would love if I could disable the other ones (aside from the default no style). That way I could style the no style option and give a site-specific selection of styles for editors to choose from. It took me a while to get my head around writing the style plugins (I used to just add classes through the panels admin section) but now that I know how I realise it's a fantastic feature for quick styling, especially through the in place editor.

The ideal situation would not only be an interface for enabling and disabling styles in the admin but a system where you could use roles and context to choose which styles were available. That way the in place editor could allow different styles on different pages and for different users which would be an amazing feature.

merlinofchaos’s picture

Okay, to do it right there probably needs to be something that is passed into the display during edit mode so that the editor can figure out proper defaults. Kind of like the setting as to whether or not there should be a display title. Then, individual apps can pass that in.

You also need to not only select a default style, but if it has config, have a form for that config.

For the panel context, which is the logical first benefactor of this functionality, the page for this should probably be somewhere hear the available content page.

Letharion’s picture

Assigned: merlinofchaos » Letharion
Status: Needs review » Needs work

Moving back to myself for work.

superjerms’s picture

Any progress on this?

Just a thought, what if new panes just inherited whatever style you set to its parent container?

clashar’s picture

And also any progress on D7?

dv8withn8’s picture

This is a pretty important feature to have. Has anyone attempted it in the 3 years this request has been open?

emattias’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev

I aim to have this feature in Semantic Panels but there is no hook (to my knowledge..) that can be used to set styling on new panes.

I created a patch that adds the drupal_alter I need. See #1985980: Allow altering of new panes

This would be a solution to atleast allow other modules to provide this feature.

I hope it was ok to change this to 7.x?

caschbre’s picture

@emattias... how do you envision setting a different default style after adding #1985980: Allow altering of new panes ?

Edit: figured it out

function MODULE_panels_new_pane_alter(&$pane) {
  $pane->styles['style'] = 'my-widget-style';
}
caschbre’s picture

What I need to figure out now is that my-widget-style also has a settings form. Any suggestions no how to kick that off for new panes?

michaelmol’s picture

@#18

In D7 this should be:

function MODULE_panels_new_pane_alter(&$pane) {
  $pane->style['style'] = 'my-widget-style';
}
thtas’s picture

Issue summary: View changes

Here is my code for this which doesn't require any patches:


/**
 * Implements hook_form_alter
**/
function MYMODULE_form_alter($form, &$form_state, $form_id) {
  if(preg_match('/_content_type_edit_form$/', $form_id)) {
    $pane = &$form_state['pane'];
    if($pane->pid == "new") {
      $pane->style = array(
        'style' => 'STYLE',   //default style name   
        'settings' => array(
         /*default style settings here*/
        ),
      );
    }
  }
}
Chris Gillis’s picture

Chris Gillis’s picture

Now that #1985980: Allow altering of new panes has been committed, it would be awesome to turn #20 into a UI setting.

mrjmd’s picture

I took a look at this, but the problems mentioned in #8 still need to be answered. Specifically, how to get at the panel variant configuration from within panels_new_pane() or panels_panels_new_pane_alter(). My work-in-progress patch is attached, which allows saving of a default but does not actually apply it to new panels yet.

Albert Volkman’s picture

Over in #2030075: Add a UI to allow someone to set default block, panel, pane settings we were discussing how this would be handy to be available for Panels and Region defaults as well. In my instance, the less user interaction required at this level, the better.

codewatson’s picture

Would it not be easier to have a global option to set what the default is, then whenever a new panel pane is added, part of the workflow of creating a new pane (no matter what type it is) would be to bring up the pane style configuration form?

Albert Volkman’s picture

Looking at the patch in #24, the main issue with using hook_panels_new_pane_alter() is that the passed in $pane object does not have a display context (did is blank). Unless we change what gets passed into panels_new_pane(), or add another alter within panels_renderer_editor::ajax_add_pane().

However, if we go the route of creating a single administration section with defaults per pane type/subtype, then that should be feasible.

joelstein’s picture

Inspired by #21, here's a hackish (but it works) way to force set a style for all regions and panes.

/**
 * Implements hook_form_FORM_ID_alter() for "panels_edit_style_type_form".
 */
function MYMODULE_form_panels_edit_style_type_form_alter(&$form, &$form_state) {
  $style = 'custom';

  if ($form_state['type'] === 'region') {
    $region = arg(6);
    $form_state['old_style'] = -1;
    $form_state['style'] = $style;
    $form_state['display']->panel_settings[$region]['style'] = $style;
    $form_state['executed'] = TRUE;
  }

  else if ($form_state['type'] === 'pane') {
    $form_state['old_style'] = -1;
    $form_state['style'] = $style;
    $form_state['executed'] = TRUE;
  }
}
joelstein’s picture

Nevermind, ignore that crazy hack I posted. It doesn't work in many situations and may result in loss of pane style configuration. :(

Chayemor’s picture

This is how I'm doing it in case it helps anyone else.

I have style set for my theme and the users are tired of having to click that "custom style" every time they create a newpanel. The featured they strongly asked for was for new panels to already have that style selected.

Only local images are allowed.

(I can't seem to add the image, this is the link for it http://oi68.tinypic.com/ndshec.jpg )

(Sorry options are in Spanish). The "custom style" is the one in all caps, and the last option was the one that was always marked by default.

Here's what I did inside one of my custom modules. You can actually determine if the panel is new by looking at its id, and then you can just alter the form's default value when that happens.

/*
	Alters the form provided by the module PANELS and STYLIZER so that the default value
	of a NEWLY created panel is always the theme's custom values located admin/config/content/classy_panel_styles
*/
function MyModuleNameOfCourse_form_alter(&$form, &$form_state, $form_id) {
  $panels_add_content_forms = array('panels_edit_style_type_form');
  if (in_array($form_id, $panels_add_content_forms)) { 
    $panel_id = explode("/", $form['#action']);
	$panel_id = $panel_id[ count($panel_id) - 1 ];
	// When a panel is just created/added its id is actually new-[a-z0-9]-* 
	// after it's saved it adopts the node's id
	preg_match('/^new\-[0-9a-z\-]*[0-9a-z]$/', $panel_id, $panel_is_new);
	if( count($panel_is_new) > 0 )
		$form["style"]['#default_value'] = "classy_panel_styles:cps_default";
	/*
	Another way of achieving the same result by inspecting the node's display and style information. If there is no style set
	then the panel with that node was just created. 
	if( array_key_exists($panel_id, $form_state["display"]->content) ){
		$target_panel = $form_state["display"]->content[$panel_id]->style;
		if( !array_key_exists('style', $target_panel) )
			$form["style"]['#default_value'] = "classy_panel_styles:cps_default";
	}*/
  }
}