Overview
Provides a way to allow content editors to override default layout builder layouts simply by creating custom blocks
Typical use case
A site builder is building a default layout for a content-type using layout builder
Whilst building it, they identify certain positions in the layout that contain components (blocks) that need to vary based on other conditions
For example, consider a University site with a course/program page. On that page the design may include a blurb about admission criteria. This criteria may vary, but not be granular enough to warrant making it a field on the course/program content-type. E.g. there may be one version for a particular Faculty, and a default for all other pages. Rather than duplicate this to all pages, the content-editor wishes to manage centrally a small set of blocks that contain the various versions of the text.
Whilst building the layout, the site-builder identifies each of these layout positions that may hold content that has variations
Using this module, they can define these positions, the rules that surround selection and a default block
Then, instead of placing a custom block in their layout, they use this module's Default Block - and nominate the 'position' they previously declared from the block configuration form
Now the content-editor can create and edit block content from the block library, and this module's selection rules will determine which block to show in the layout
Selection rules are controlled by a plugin system. The module ships with a sub-module that uses common-terms, allowing selecting a block which has the most terms in common with the piece of content the layout displays.
Features
- Define layout positions
- Configure block selection criteria for each layout position
- Define a default block for each layout position
- CMI integration to create (empty) default blocks via config
- Select blocks with the most matching common terms (via submodule)
- Token support, if the block contains e.g.
[node:title]in its fields, these are replaced with the actual node title. This allows for the default blocks to appear as though they're unique to a given piece of content
Dependencies
The base module relies on block content from core only.
The common terms sub-module relies on
Installation/Configuration
- Install with composer
composer require drupal/lb_default_blocks - If you intend to use the common-terms submodule, also add backfill formatter
composer require drupal/backfill_formatter - Identify the block-types you wish to make available as default blocks.
- For each of these, edit the block type and enable the Default blocks functionality using the checkbox. This will add a new 'Position' field to each of them
- Identify the positions in the layout you want to populate from the block-content library
- Create a layout position for each of those from
/admin/structure/layout-positions - For each position, configure the selection criteria
- If using the Common-terms sub-module, be sure to configure Taxonomy Entity Index to index the entity-type you're displaying with Layout Builder (most likely Nodes/Content) and the Block Content entity-type. You may need to re-index to populate the database for existing content.
- From your layout builder page, place the 'Default Block' block in the desired position, and select the previously created layout position.
- If you have views enabled, visit
admin/content/default-blocksand create new blocks - selecting a position and populating other fields as required
Known Issues
Please use the issue queue to report any problems
Recommended modules
You may wish to consider adding the Block access module to support content-editors creating blocks with needing to grant them the 'Administer Blocks' permission.
Project information
Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: Content display
- Ecosystem: Layout Builder
1 site reports using this module
- Created by larowlan on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.



