Implement hook_panelizer_clone_panelizer() so that when a display is cloned any nested FPP objects are also cloned.

Comments

DamienMcKenna created an issue. See original summary.

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new1.68 KB
damienmckenna’s picture

Status: Needs review » Needs work

This needs extra work to handle reusable FPPs, which shouldn't be cloned.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new1.78 KB
new629 bytes

Don't clone reusable FPPs.

dsnopek’s picture

Status: Needs review » Needs work
  1. +++ b/fieldable_panels_panes.module
    @@ -1658,3 +1658,45 @@ function fieldable_panels_panes_entity_delete($entity, $type) {
    +      list($type, $id) = explode(':', $pane->subtype);
    

    This line should be removed: the code doesn't use $type or $id from here, it does this again later on right before it's used...

  2. +++ b/fieldable_panels_panes.module
    @@ -1658,3 +1658,45 @@ function fieldable_panels_panes_entity_delete($entity, $type) {
    +      list($key, $id) = explode(':', $pane->subtype);
    +      $pane->subtype = $key . ':' . $new_pane->{$key};
    

    ... right here!

  3. +++ b/fieldable_panels_panes.module
    @@ -1658,3 +1658,45 @@ function fieldable_panels_panes_entity_delete($entity, $type) {
    +      // Reset the primary keys.
    +      $new_pane->fpid = NULL;
    +      $new_pane->vid = NULL;
    +      $new_pane->vuuid = NULL;
    +      $new_pane->uuid = NULL;
    +      $new_pane->is_new = TRUE;
    

    Do we also need to reset 'timestamp' and 'created'? I'll do some testing later

dsnopek’s picture

+++ b/fieldable_panels_panes.module
@@ -1658,3 +1658,45 @@ function fieldable_panels_panes_entity_delete($entity, $type) {
+      list($key, $id) = explode(':', $pane->subtype);
+      $pane->subtype = $key . ':' . $new_pane->{$key};

Oh, and this will fail badly for the 'current:' prefix since there is no 'current' key - that uses the fpid. So, this needs a little extra logic for that.

dsnopek’s picture

Status: Needs work » Needs review
StatusFileSize
new1.88 KB
new2.27 KB

Here's a new patch that addresses my review above, and also renames same variables for clarity. The patch was previously using $content for the original FPP entity, and $new_pane for the cloned FPP entity, which was confusing because there was also $pane which was the Panels pane (so there was an asymmetry between $pane and $new_pane).

So, I changed:

  • $content to $fpp
  • $new_pane to $new_fpp

This shows the relationship between the original and new FPP entity, and removes any confusion with the pane.

Still untested - sorry :-)

dsnopek’s picture

Ok, finally got around to testing this in conjunction with the latest patch on #2070891-44: Support core Content Translation by cloning the Panelizer display for the new entity and it worked great!

I dug into the database, same as I did on #2975438-2: Clone FPP entities when cloning a Panelized node via 'node_clone', to confirm that everything looked as it should and it did :-)

cboyden’s picture

Status: Needs review » Reviewed & tested by the community

We've been using this patch, in conjunction with the one in #2070891: Support core Content Translation by cloning the Panelizer display for the new entity, and it's working. Cloning a panelized entity creates cloned FPPs appropriately, and handles reusable FPPs correctly.

damienmckenna’s picture

That's fantastic, thanks for the update cboyden!

  • DamienMcKenna committed b711e48 on 7.x-1.x
    Issue #2962952 by DamienMcKenna, dsnopek, cboyden: Implement...
damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.