- 🇨🇷Costa Rica keboca
I had the same problem, but I've found a way to solve it (at least for me). Basically, I added a new
\Drupal::moduleHandler()->alter()
right after the cloned parent renders the parent field within the
\Drupal\paragraphs_previewer\ControllerParagraphsPreviewController::paragraphsPreviewRenderParentField
method.
It allows me to alter the "$parent_view_mode" variable in order to render the same way as the module does but using another view mode that I've created only to render the correct field in the proper way. In a nutshell, I just rerun this line:
$elements = $parent_clone->{$parent_field_name}->view('paragraphs_preview');
- 🇪🇸Spain idiaz.roncero Madrid
Same here, I noticed that this module nevertheless DOES use a config that is not exposed via an admin UI (a module settings form) but exists:
$parent_view_mode = \Drupal::config('paragraphs_previewer.settings')->get('previewer_view_mode');
So, if you are using the full view mode via Layout builder, you are doomed... unless you manually change the exported
paragraphs_previewer.settings.yml
and manually set your preferred view mode.A solution proposal would be the following:
- Expose a module settings form that allows the developer to choose a different view mode
- Better errors: trigger a warning if the view mode in use is using layout builder in order to let the developer know what's happening, and/or instead of
No preview available.
print something likeIt seems the view mode you are using to render this paragraph is using Layout Builder, which is unsupported. Please use the module settings to switch to a different view mode.
"I'm encountering a similar issue when using the Paragraphs Previewer module alongside Paragraphs Layouts. Instead of seeing no preview available, I get the following error:
'Call to undefined method Drupal\layout_paragraphs\Form\InsertComponentForm::getEntity() in Drupal\paragraphs_previewer\Controller\ParagraphsPreviewController->onForm() (line 55 of modules/contrib/paragraphs_previewer/src/Controller/ParagraphsPreviewController.php).