Consider template blocks or semi-global shared blocks #6297
Labels
[Feature] Synced Patterns
Related to synced patterns (formerly reusable blocks)
[Feature] Templates API
Related to API powering block template functionality in the Site Editor
Issue Overview
Currently, a shared block is identical to every other instance of that shared block. This is useful for things like footers. However, there are cases where you want to have the same style of something, but with different content in every place it is used. The proposal for "block templates" in #3588 partially covers this, but that is a list of blocks that is used when initially creating a page and I am guessing you would not be able to have multiple templates in a single instance of the editor.
Multiple page builder plugins (including Beaver Builder, Divi, and Elementor) include some form of template system for their modules/widgets, where you can drop in a template and then edit it to fit the particular page. The templates are sometimes singular modules, but other times include rows/sections or even multiple rows/sections, almost becoming a list of blocks similar to the proposal for "block templates" in #3588.
In the context of Gutenberg, sections, rows, columns, and the stuff inside columns are all just blocks, so a template block system could work by simply allowing for a block to be saved as a template that could be inserted from the block inserter. Of course, editing these template blocks would have to be different than with shared blocks, because once a template block is inserted, the resulting block has no idea it came from a template, so editing or removing a template block would have to be done through some other UI. Most page builder plugins have a library of templates that is used to manage templates.
And then there are cases where you have something that is a sort of hybrid template/shared block. Some properties are global, but others are not. Divi has a feature called Selective Sync that allows you to have global modules with your choice of which features are global and which are local to each instance of the module.
https://www.elegantthemes.com/documentation/divi/selective-sync/
Now, some cases of where this would be used (page titles that are different from the
<title>
title) will be covered when Gutenberg gets the ability to modify areas outside ofpost_content
. The proposed "block templates" will cover other situations. However, I think there will still be cases where a shared block with some properties made local instead of global would be quite useful.Side note: Given their current proposed functionality, the "block templates" should probably be called "page block templates" instead since they are more like or perhaps even the replacement for the page templates that currently exist in WordPress, while the "template blocks" idea refers to something that is inserted from the block inserter in an instance of the editor.)
So as far as I can see, the best approaches to this issue would be to extend the shared blocks system to support having some properties be made local (preferably chosen by the user).
Even if the "selective sync" feature is deemed unnecessary, having template blocks would still be a nice feature, so that would have to be implemented somehow, and I can see 3 ways of doing it:
As you can see, this is a bit of a complicated subject. The concepts of shared blocks, template blocks, "block templates"/page templates all start to blend into each other... especially if you include the "selective sync" functionality. I am not entirely sure where one should end and the other should begin.
It should be noted that this should not be confused with the concept of "global block settings", which would be settings that apply to every instance of a block, and possibly also the default settings of a block.
Related Issues and/or PRs
post_content
#1684template_lock
option with block templates #5208The text was updated successfully, but these errors were encountered: