Layout builder preview failing

Created on 20 September 2021, almost 3 years ago
Updated 24 January 2024, 5 months ago

Problem/Motivation

Since installing this module I'm having a non-fatal issue with content preview in layout builder.

The issue is: If I add, open ("configure"), or "move" a views block in layout builder, the views block says "Placeholder for the 'name' views block," as if the block were empty (it isn't).

I'm not sure how to begin troubleshooting this but can try with some direction.

Steps to reproduce

This occurs in both Opera V and Chrome 93.0, Drupal core 8.9.18-dev. I was able to reproduce it:

1. composer create-project drupal/recommended-project:8.9.x-dev SITENAME
2. composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader drupal/devel drupal/views_arg_entity_field
3. drupal module:install devel devel_generate layout_builder views_arg_entity_field views_ui
4. open "article" content type, add "issue" field for use in contextual filter
5. on "manage display" tab, enable layout builder for individual nodes on article content type
6. create a taxonomy vocabulary and some term(s)
7. generate some article nodes
8. open a few nodes and add a taxonomy term
9. add an arbitrary (but matching) string in "issue" field
10. create a view block filtered on a taxonomy term, and with a contextual filter on "issue" field.
11. go to "layout" tab of one node
12. add view block to node layout; preview shows placeholder even if view block has content
13. save layout, return to "layout" tab; preview now shows view block content
14. back to "layout" tab; select either "configure" or "view" link, then "update" or "move" -- preview again shows placeholder
15. save layout, return to "layout" tab; preview now shows view block content again

Proposed resolution

No idea yet

Remaining tasks

User interface changes

API changes

Data model changes

(Yes, I know D8 is nearing EOL but this is a D7 migration so I have more than year yet, and I need some other contrib modules that weren't D9 ready when I last checked.)

πŸ› Bug report
Status

Needs review

Version

2.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States rclemings

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡·πŸ‡ΊRussia zniki.ru

    I was able to replicate this on Drupal 10.2.
    Thanks for detailed explanation, I want to add that you need to enable "Allow each content item to have its layout customized." option on Article manage display.

    This happens when you move block, and request to layout_builder.move_block route is made.

      public function getArgument() {
        $value = NULL;
        // $this->options['entity_type_id'] is "node" in my case.
        if ($entity = $this->routeMatch->getParameter($this->options['entity_type_id'])) {
        }
       
        return $value;
      }
    

    As you can see from the code for route layout_builder.move_block getParameter('node') will be null.
    And if clause if FALSE, and getArgument returns NULL. That is the reason of this issue.

    In my case I have:
    Node URL: /node/149/layout
    When I move blocks
    AJAX requestUri: /layout_builder/move/block/overrides/node.149/0/0/content/9e02ecfc-2654-4e95-b554-db1808cebb1e?_wrapper_format=drupal_ajax

    So looks like section_storage is node.149.
    I think you can get desired entity, but only as customization.
    I don't know how this can be implemented in a contrib module as universal solution.

    Maybe someone have any ideas?
    We need to find the way how to get original url, to get entity object.

    Not sure what status to set. Set it to Needs review for now.

  • πŸ‡·πŸ‡ΊRussia zniki.ru

    I was able to find solution, not sure if I will merge it to code base.
    But you can use it as patch.

    Please test it and provide feedback.

Production build 0.69.0 2024