Skip to content

Instantly share code, notes, and snippets.

Created May 10, 2018 00:43
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
How to add a pane to a node with panelizer programmatically
// This code can be used in a hook_update_n to add a custom pane to an existing display in panelizer.
// Example variables used in the code below.
$nid = 1;
$pane_machine_name = 'my_example_custom_pane';
$region = 'content';
$position = 0;
// Load the node and save its display as modified, this is required so panelizer knows there's new stuff.
$node = node_load($nid);
$node->panelizer['page_manager']->display_is_modified = TRUE;
// Change the display.
$display = panels_load_display($node->panelizer['page_manager']->display->did);
$new_pane = panels_new_pane($pane_machine_name, $pane_machine_name, TRUE);
$new_pane->panel = $region;
$new_pane->position = $position;
$display->panels['main-content'][] = $new_pane->pid;
$display->content[$new_pane->pid] = $new_pane;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment