Problem/Motivation

Support for https://www.drupal.org/project/layout_paragraphs Layout Paragraphs? I have used this in the past, but on our new sites we now use Layout Paragraphs, when exporting content I just get the following (Paragraph Id's but no content). Based on the module description I think the content for paragraphs should exist in the exported files?

default:
  depends:
    70654b51-baa8-46b7-9edb-2d7ff086010f: paragraph
    a92c2288-d333-433c-b91c-d8331f2b92b5: paragraph
 field_sections:
    -
      entity: 70654b51-baa8-46b7-9edb-2d7ff086010f
    -
      entity: a92c2288-d333-433c-b91c-d8331f2b92b5

Steps to reproduce

1. Use https://www.drupal.org/project/layout_paragraphs
2. Create a sample page to test exporting with some layout paragraphs content.
3. run something like drush dcer node 1 --folder=TARGET_PATH/content
4. see Paragraphs Id's but no content in export.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

NicholasS created an issue.

itamair’s picture

I am also experiencing great limitations in my use case with Layout Paragraphs. Opened a kind of (potentially) related bug issue here: https://www.drupal.org/project/default_content/issues/3352977

jorgediazhav’s picture

I found a workaround for this, and I hope it somehow gives an insight for possible solutions.

I have a node with a paragraph reference field (LVL1) that then has a field reference that aims towards other paragraphs (LVL2). The problem was, as stated before by @nicholass , the LVL 2 paragraphs are mot being exported.

The structure is somehow like this:

Node
------> Paragraph LVL 1
---------------> Paragraph LVL 2 #1
---------------> Paragraph LVL 2 #2

The workaround:

First, I export a node like this:

drush dcer node NODE_ID --folder=../recipes/RECIPE_NAME

Then, I run the following in the command line to identify all the paragraphs IDs that are referenced in LVL2:

drush php-eval '
$node = \Drupal\node\Entity\Node::load(NODE_ID);
$nested_ids = [];

// Loop through first-level paragraphs.
foreach ($node->get("field_PARAGRAPHS_LVL1")->referencedEntities() as $paragraph) {
    if ($paragraph->hasField("field_PARAGRAPHS_LVL2")) {
        foreach ($paragraph->get("field_PARAGRAPHS_LVL2")->referencedEntities() as $nested) {
            $nested_ids[] = $nested->id();
        }
    }
}

// Remove duplicates
$nested_ids = array_unique($nested_ids);
sort($nested_ids);

// Export commands
foreach ($nested_ids as $id) {
    echo "drush dcer paragraph $id --folder=../recipes/RECIPE_NAME\n";
}
'

This will generate a list of commands like this (with the respective LVL2 paragraph IDs):

drush dcer paragraph 24693 --folder=../recipes/RECIPE_NAME 
drush dcer paragraph 24694 --folder=../recipes/RECIPE_NAME 
drush dcer paragraph 24695 --folder=../recipes/RECIPE_NAME 
drush dcer paragraph 24696 --folder=../recipes/RECIPE_NAME

Then, by running those commands, all paragraphs get generated under the RECIPE_NAME/paragraph/ folder.

Then, importing will work (paragraphs LVL2 will be created and properly referenced from the LVL1 paragraph and the Node). The problem mentioned on this issue actually occurs ONLY during the export, as the import will pick all paragraphs from the "/paragraph" folder and the entities will be created in the DB.

Hope it helps!