Problem/Motivation

Repeatable: Always
Steps to repeat:
1. Enable Book module
2. Create a new Book page
3. Visit a new created page, see "Add child page" and "Printer-friendly version" on the page
4. Enable Layout builder module (but do not configure it further)
5. Clear the Drupal cache
6. Visit the page from step 3

Expected Results:
"Add child page" and "Printer-friendly version" on the page

Actual Results:
"Add child page" and "Printer-friendly version" are absent

Alternate steps to reproduce:
Create a new Article node
Install Layout Builder (but do not configure it further)
Visit the front page

Expected results:
"Read more" links are available below node teasers

Actual results:
"Read more" links are missing

Proposed resolution

Fix the check in layout_builder_entity_view_alter() to ensure that extra field replacements are needed.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Comments

xopoc created an issue. See original summary.

tim.plunkett’s picture

Version: 8.6.x-dev » 8.7.x-dev
Status: Active » Postponed

I believe this is due to #3001313: Field blocks in the layout builder do not have view mode suggestions
Leaving postponed instead of closing as a duplicate, for now.

stompersly’s picture

This problem also exists in Drupal 8.6.4.
1. Enable Layout builder module
2. "Add child page" and "Printer-friendly version" are absent

I am trying to uninstall layout builder but ran into this issue:
Layout Builder cannot be uninstalled while overrides exist; no easy way to revert all overrides

lukasss’s picture

I also see this in the comment links.
I think the problem extends to all fields-links.

tim.plunkett’s picture

Title: Layout builder prevents the rendering of Links field on pages using view modes. » Layout builder prevents the rendering of extra fields (like Links) on pages not using Layout Builder
Issue summary: View changes
Status: Postponed » Needs review
Issue tags: +Needs tests
StatusFileSize
new1.54 KB

Oh, I made some very incorrect assumptions about the steps to reproduce. I was enabling Layout Builder for Book nodes, which works fine. The problem is when Layout Builder is NOT enabled.

This is also reproducible without Book module: node teasers have "Read more" links

Here's a fix. The current conditional will always be TRUE when the module is installed, regardless of configuration.

lukasss’s picture

StatusFileSize
new1.53 KB

The patch doesn't work, causes an error.
I think needed use empty().

lukasss’s picture

StatusFileSize
new1.29 KB

Deleted unnecessary

tim.plunkett’s picture

What error does it cause?
That patch will not work since the array will always contain #cache information and will never be empty

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett
Status: Needs review » Needs work

Oh it will be an undefined index error in some cases. Okay, working on this now.

tim.plunkett’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new1.03 KB
new2.61 KB
new1.94 KB

Needs the isset() for sure in 8.6, less important in 8.7 but still worth having.

The last submitted patch, 10: 3007973-extrafields-9-FAIL.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 10: 3007973-extrafields-9-PASS.patch, failed testing. View results

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new1.1 KB
new2.67 KB

Test addition conflicted with #2938132: Ship layouts that make sense with Layout Builder's concept of sections.
Interdiff was correct though.

The last submitted patch, 13: 3007973-extrafields-13-FAIL.patch, failed testing. View results

lukasss’s picture

#13 works.
TNX. Good job!

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned

Glad to hear it. Ready for final review!

bnjmnm’s picture

Status: Needs review » Needs work
Issue tags: +Blocks-Layouts
+++ b/core/modules/layout_builder/layout_builder.module
@@ -106,7 +106,7 @@ function layout_builder_field_config_delete(FieldConfigInterface $field_config)
-  if ($display instanceof LayoutEntityDisplayInterface) {
+  if (isset($build['_layout_builder']) && !Element::isEmpty($build['_layout_builder'])) {

Add comment describing what the conditional is checking

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new2.84 KB
new950 bytes

Ahh good point, knowing where that '_layout_builder' string comes from would be tricky without a comment.

bnjmnm’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed and tested:

  • Without Layout Builder enabled, created a new book page (worth noting I also chose "Create a new book" in the Book Outline tab, which was necessary to make "Add child page" and "Printer-friendly version" visible on this book page.
    - Enabled Layout
  • Enabled Layout builder, cleared cache, and verified that "Add child page" and "Printer-friendly version" were no longer present
  • Applied 3007973-extrafields-18.patch, cleared cache then confirmed that "Add child page" and "Printer-friendly version" were again visible
  • Reviewed code and concluded it is quite easy to follow, with comment was added in the single spot where further explanation might be helpful
  • Checked the new testExtraFields() test pre and post-patch.
tim.plunkett’s picture

Issue summary: View changes

Thanks! Update the IS to include the non-book module approach to reproduce.

xjm’s picture

Version: 8.7.x-dev » 8.6.x-dev

This looks like a straight-up bugfix with no disruptions and @stompersly documented that it also exists in 8.6.4, so it should be backported.

Sending for an 8.6.x test run.

tim.plunkett’s picture

Moving the method higher up in the class so it applies to 8.6 and 8.7

  • xjm committed fea6c51 on 8.7.x
    Issue #3007973 by tim.plunkett, lukasss, xopoc, bnjmnm, stompersly:...

  • xjm committed 7881637 on 8.6.x
    Issue #3007973 by tim.plunkett, lukasss, xopoc, bnjmnm, stompersly:...
xjm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.7.x and cherry-picked to 8.6.x. Thanks!

I added issue credit for @stompersly since the comment helped me notice it should be backported. :)

Status: Fixed » Closed (fixed)

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

ariane’s picture

In core version 8.6.9 the patch in #22 dont apply.

I think is due to different line numbers in the file layout_builder.module

lukasss’s picture

The patch has already been committed in 8.6.8
https://www.drupal.org/project/drupal/releases/8.6.8