Skip to content

Instantly share code, notes, and snippets.

@davereid
Created August 17, 2012 21:43
Show Gist options
  • Save davereid/3382971 to your computer and use it in GitHub Desktop.
Save davereid/3382971 to your computer and use it in GitHub Desktop.
Changing layout of panel on the fly
/**
* Implements hook_panels_pre_render().
*/
function custom_panels_pre_render($display, $renderer) {
// To switch a panel's layout on the fly, you need to not only set
// the display's layout, but also swap out the layout plugin in the
// renderer object.
ctools_include('plugins', 'panels');
if ($plugin = panels_get_layout($layout)) {
$display->layout = $layout;
$renderer->plugins['layout'] = $plugin;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment