Search code examples
drupaldrupal-panels

Panels added via Panelizer are deleted after going to node/edit and saving the node


I create an article and then "Customize this page" and add a panel to the page. I can re-save that page using panelizer over and over again with no issues. However, when I go into the "new draft" page and edit and publish the node, all items that were added with panelizer are removed from the article.

Very similar to this https://drupal.org/node/1572202 with the difference being that I notice it happens when I save from the node/edit page. I already have the patch on that page applied because it was added to the latest version of panelizer which I have.


Solution

  • There are known issues with panelizer, if you are using the Workbench module. Basically, the association between the revision and the panelized node gets lost.

    There is a detailed explanation here: http://www.phase2technology.com/blog/panelizer-and-workbench-moderation-can-get-along/

    It will probably need some adaptation for each config, but this should get you started:

    function MYMODULE_node_update($node) {
      if (!empty($node->old_vid)) {
        // fetch the did from the old revision
        $old_did = db_query("SELECT did FROM {panelizer_entity} WHERE entity_id = :nid AND    revision_id = :oldvid ORDER BY revision_id DESC",
        array(":nid" => $node->nid, ":oldvid" => $node->old_vid))
      ->fetchField();
        if (!empty($old_did) && !empty($node->panelizer['page_manager']) && empty($node->panelizer['page_manager']->did)) {
        $node->panelizer['page_manager']->did = $old_did;
        }
      }
    }