Hi,
I'm not sure if the issue I was having is directly because of Layout builder library, but I'm not able to reproduce it without it.

Steps to reproduce (not 100% accurate, as I've done many tries):

* On a Page content type create a couple of view modes (at least 2 – teaser and full)
* Both uses Layout builder with different layout
* Create an entity reference field for referencing pages.
* Create a new Layout in layout library for Page
* Place the entity reference on it – set formatter to display Teaser view mode
* Create some content, make references – all should look fine at this point
* Go to the teaser view mode and do some changes – save
* Go back to demo page – the teaser are now rendered as a Full view mode (in case of one content type it will probably ends with some looping error, in case of two content types it just use the wrong template).

Are there some step I should avoid? E.g. don't use Layout builder on a Full view mode together with LBL?

This issue leads me to uninstall Layout Builder Library in the end.
I like the idea of the module, but in the end It was better for me to have view modes with layout than multiple full view mode variants.

Comments

Petr Illek created an issue. See original summary.

petr illek’s picture

Anonymous’s picture

I have the same issue. A selected layout from the layout library applies to all view modes, not just on view mode where "Allow content editors to use stored layouts" option is enabled.

dejanp’s picture

Status: Active » Needs review
StatusFileSize
new1.29 KB

The selected layout from the library overrides all view displays.
It should probably check whether the option "Allow content editors to use stored layouts" is enabled on a specific display or not.

I'm not sure that this is the right solution, but it will fix the problem.

larowlan’s picture

Issue tags: +Needs tests

Thanks for the patch, we need a test here too

  1. +++ b/src/Plugin/SectionStorage/Library.php
    @@ -263,8 +263,22 @@ class Library extends SectionStorageBase implements ContainerFactoryPluginInterf
    +      $entity_view_display = \Drupal::entityTypeManager()
    

    We can inject this

  2. +++ b/src/Plugin/SectionStorage/Library.php
    @@ -263,8 +263,22 @@ class Library extends SectionStorageBase implements ContainerFactoryPluginInterf
    +      if(!is_null($entity_view_display)) {
    

    we can just use if ($entity_view_display) here

dejanp’s picture

StatusFileSize
new4.56 KB

Patch update, including the test as well.

larowlan’s picture

Issue tags: -Needs tests

Thanks

Status: Needs review » Needs work

The last submitted patch, 7: 3053965-7.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

dejanp’s picture

Status: Needs work » Needs review
StatusFileSize
new4.56 KB

I fix the test. It should pass now on Drupal 8.8.

Status: Needs review » Needs work

The last submitted patch, 10: 3053965-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

larowlan’s picture

Status: Needs work » Needs review
larowlan’s picture

Status: Needs review » Fixed

Fixed on commit:

--- a/tests/src/Functional/LayoutDisplayTest.php
+++ b/tests/src/Functional/LayoutDisplayTest.php
@@ -68,7 +68,8 @@ class LayoutDisplayTest extends BrowserTestBase {
     $page->pressButton('Add block');
     $page->pressButton('Save layout');

-    // Enable full content display, then enable layout builder and library on the default view display.
+    // Enable full content display, then enable layout builder and library on
+    // the default view display.
     $this->drupalGet('admin/structure/types/manage/cats/display');
     $page->checkField('display_modes_custom[full]');
     $page->pressButton('Save');

Cutting a new release

  • larowlan committed 2def152 on 8.x-1.x authored by pinkdexo
    Issue #3053965 by pinkdexo, larowlan: Layouts in layouts picking wrong...
larowlan’s picture

Issue summary: View changes
StatusFileSize
new36.5 KB

Cut a new release, beta1 - thanks @pinkdexo

dejanp’s picture

Thanks @larowlan :)

Status: Fixed » Closed (fixed)

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