You are here

function panelizer_clone_node_panelizer in Panelizer 6

Same name and namespace in other branches
  1. 7 includes/node.inc \panelizer_clone_node_panelizer()

Helper function to clone a node's panelizer object and the panels display.

Parameters

stdClass $panelizer: The fully-loaded panelizer object for a given node.

integer $nid: The nid to use for the cloned panelizer.

Return value

stdClass A cloned and fully-loaded panelizer object.

2 calls to panelizer_clone_node_panelizer()
panelizer_load_node_panelizer in includes/node.inc
Retrieve the panelizer panel associated with a node.
panelizer_node_insert in ./panelizer.module
Implements hook_nodeapi() for insert (D7's hook_node_insert()).

File

includes/node.inc, line 54
Contains routines specific to handling nodes that are panelized.

Code

function panelizer_clone_node_panelizer($panelizer, $nid) {
  $panelizer_clone = drupal_clone($panelizer);

  // To ensure this saves properly later, we need to scrub out the data that
  // is specific to the default.
  unset($panelizer_clone->name);
  unset($panelizer_clone->title);
  $original_display = panelizer_load_display($panelizer);

  // In order to ensure we don't actually use and modify the default display,
  // we export and re-import it.
  $code = panels_export_display($original_display);
  ob_start();
  eval($code);
  ob_end_clean();
  $panelizer_clone->display = $display;
  $panelizer_clone->did = NULL;
  $panelizer_clone->nid = $nid;
  $panelizer_clone->new = TRUE;
  return $panelizer_clone;
}