Some months ago I created a feature request and a patch to "simplify the browser form": https://www.drupal.org/project/layout_builder_browser/issues/3306544
I am now working on another project and the customer's request around the browser form are slightly different. I realise that the approach I followed is still restrictive to the option listed.
I would suggest that block items in the browser are displayed using a theme function so it is easier for any custom module to override the default template.
I also suggest to integrate the preview image with the image style to ease the uniformisation of the images.
Finally, as requested in another ticket, adding a short description can also be very useful. By default it would be displayed under the block label but it is very simple by overriding the template to make it appear somewhere else (as a tooltip for example).
Issue fork layout_builder_browser-3349340
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:
- 3349340-browser-block-item
compare
- 8.x-1.x
changes, plain diff MR !14
Comments
Comment #3
vbouchetPlease find a MR which tries to have as little opinion as possible on how the browser should be displayed. It should not have impact on existing sites given the default image style is "Original" and description field is optional.
Comment #6
vbouchetComment #8
pierreemmanuel commentedHi,
I tried to use the template added by the commit "cfec02e3". I found that the template is a sub-template per block and is not used by default.
In a custom module:
I have added the theme with "hook_theme()"
With "hook_layout_builder_browser_alter()" have added the theme the sub elements as such:
The template is called for every block type but, unfortunately, I did not manage to get the correct variables for the template "layout-builder-browser-block.html.twig".
In the hook_theme I tried both defining variables or render element.
Am I misunderstanding the intention of this template ? Did someone succeed to render the layout builder browser modal with a template ?
Thanks,