Exporting a simple layout and trying to re-import it results in the following error

warning: Invalid argument supplied for foreach() in ****/sites/all/modules/panels/includes/plugins.inc on line 612.

The panel page that has been created has no content or layout settings.

This may well be something being worked on but I thought I should point it out just in case.

Thanks
Gregg

Comments

wlx20005’s picture

Hi I get the same question. and insert 3 Lines code in \sites\all\modules\panels\panels_page\panels_page.write.inc, It works!

<?php
function _panels_page_insert(&$panel_page) {
  $fields = $types = $values = array();

  // Save the primary display, thus creating a $display->did.
  // insert begin --------------------------
  if(empty($panel_page->primary) && !empty($panel_page->display)) {
  	$panel_page->primary = &$panel_page->display;
  }
  //insert end --------------------------
  panels_save_display($panel_page->primary);
  $schema = drupal_get_schema('panels_page');

  $clone = drupal_clone($panel_page);
  $clone->did = $panel_page->primary->did;

  foreach ($schema['fields'] as $field => $info) {
    if (isset($panel_page->$field) && $info['type'] != 'serial') {
      $fields[] = $field;
      $placeholders[] = db_type_placeholder($info['type']);
      $values[] = _panels_page_save_value($info, $clone->$field);
    }
  }

  // Build the query adding the new pid and did.
  $sql = 'INSERT INTO {panels_page} (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $placeholders) . ')';

  db_query($sql, $values);

  $panel_page->pid = db_last_insert_id('panels_page', 'pid');

  // Return the pid for convenience.
  return $panel_page->pid;
}
?>

smithn.nc’s picture

Just tested this out, it worked beautifully, and beats rebuilding a complex panel page from scratch every time. Thanks!

jruberto’s picture

Tested this as well, works great. Thank you!

If you can, kindly roll this into a patch so that it hits the next release. Thanks again!

smithn.nc’s picture

It appears I spoke a little too soon. If you've got a panel that has several displays (I'm using one per taxonomy argument to the panel), you can't export this panel page and import it correctly. None of the displays hold their data correctly if you do.

scottrigby’s picture

Status: Active » Needs review

@wlx20005: thanks -- #1 works for me

@smithn.nc: Do you mean several views displays? I imported a panel with multiple views displays after this adjustment, and all works for me. but maybe that's not what you mean?

smithn.nc’s picture

@scottrigby: I am referring to Panels with additional displays for each argument coming in. For instance, I created a Panel that has two arguments, and has a different content display depending on the number of augments it receives.

When I export and then import that Panel, the newly imported Panel page does not reliably save changes. Sometimes it will remember things I change in the display, other times I can save the content display, come back and everything will be like it was when I imported, or sometimes missing altogether. It doesn't have anything to do with using more than one view in a display. Thanks.

merlinofchaos’s picture

Status: Needs review » Closed (fixed)

No longer relevant.