Problem/Motivation
The current implementation requires a separate computed field with a list of relationships for all blocks.
Proposed resolution
I have implemented more simplified logic that works well without a separate field and works well with reusable blocks too.
Also, it provides support for including fields from the "default_include" list, provided by jsonapi_extras module (jsonapi_defaults submodule).
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3374355.patch | 25.62 KB | quadrexdev |
| #9 | 3374355-9.patch | 25.6 KB | kevinquillen |
| #8 | 3374355-3.patch | 24.6 KB | kevinquillen |
| #7 | 3374355-2.patch | 23.55 KB | kevinquillen |
| #6 | 3374355-1.patch | 22.98 KB | kevinquillen |
Issue fork jsonapi_include_lb-3374355
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
murzFor my cases it works well, so let's move to "Needs review" to check how it works for others.
Comment #4
murzComment #5
kevinquillen commentedWill this recursively load info for blocks that have entity reference fields (Media, taxonomy, etc)?
Comment #6
kevinquillen commentedHere is a quick add on for this patch that does the following:
$item['layout_builder__layout']is empty.$item['layout_builder__layout']with that information and proceed as normal - adding the entity view display entity as a cacheable dependency.This was important in getting layout builder information for decoupled sites for nodes that are NOT overridden, or may not be able to be overridden in layout builder. Otherwise, the array is empty - but you DO have layout builder information at the display level. It should pass it.
Comment #7
kevinquillen commentedAttaching a second patch. This one will sort the blocks in their proper order so it is easier to work with on the client side.
Comment #8
kevinquillen commentedI noticed that core does not store the order of items correctly, region or weight. This updated patch attempts to set that order while building the response so the frontend does not have to bear that burden.
Comment #9
kevinquillen commentedUpdating patch. Reworked some of the logic and addressed issues when viewing entities that are not Layout Builder enabled.
Comment #10
quadrexdevWe used the patch from #9 in our project and it worked fine except for supporting the includes tree.
Our case:
Node with layout builder, inside layout builder layout added some blocks with paragraphs (just a basic block type with a paragraph field) -> paragraphs were not included even after configuring default includes.
What helped:
Adding "include" parameter before
Attaching patch file
Comment #11
kevinquillen commentedThat could have been overlooked, sure - I don't use Layout Paragraphs or Paragraphs.
Comment #12
the_g_bomb commentedI grabbed this patch along with the one for D11 readiness, both applied nicely, and I am now getting my node information for layout builder for nodes just using the default layout. I can't speak for paragraphs as I don't have those. If I get time, I will try to test further. Looks good to me, though. Thank you