-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Present Blocks outside of post_content
#1684
Comments
@brentjett I think this is what we've been talking about just now in #952 (comment):
It would be helpful to have some design guidelines for how such “metablocks” are styled. |
I wonder what would it look a like for WooCommerce. |
I've been trying to flesh this idea out further just to see where it leads. Below is a fictitious example of a custom post type for a movie review. In this situation the developer has created a custom "Movie Details" block that is required for this post type, but could very well be an available block on a standard post. There seems to be a need for "Sections" to help inform the user what's happening. In this scenario the only blocks that should be considered It may be helpful to imagine that certain situations might require multiple freeform/open block sections, but only one of those would correspond to the Here's an example with the Settings section supporting a variable number of blocks. I'm wondering if we could use the same UI pattern as the block picker for the content blocks to accomplish what the Screen Options tab (top right, standard edit screens) does now. Here the picker is showing available "meta" blocks. If I have time I'll try to do a WooCommerce example. There's a lot going on there, so it's a bit time consuming. |
related #2065 |
For me this is the main requirement for fully being able to transition away from meta boxes to blocks. I'm currently experimenting with how to port over some plugin meta box functionality to Gutenberg blocks. I have been able to create a block that saves as post meta so it can continue to use the existing data structure. I have also defined a block template so that the block is shown by default. The meta fields block is required for all posts in the post type and should be locked so it cannot be deleted. It should also be shown in a consistent non-moveable place when editing. Currently if I set What is required is to be able to lock just a specific block to prevent it being moved/deleted while continuing to be able to add/insert/move other blocks in the editor? This could work using a separate section as outlined above by @brentjett , or perhaps be defined by a block template that allows the meta block to be position where desired in the template, above or below the main content blocks area, and just lock that block. It feels list some implementation of |
This will be possible using nested blocks, where you add can add a "container" block allowing the user to add/remove/insert any block inside this container block while the others remain locked. |
Thanks @youknowriad. I had read a bit about nested blocks but couldn't find an examples at present. The only example of block locking I found was at a template level where you can specify |
@benhuson Yes but if you think about it, it's enough for all use-cases. While the container block can't be moved/removed, you can still insert/remove blocks inside it. You could imagine having a "lock" attribute in the container block allowing you to "sub lock" parts of the editor. This is just ideas for now, once #3745 lands we'll experiment with this more. |
@brentjett @benhuson Any remaining actionable items out of this issue or can it be closed? |
There's been a lot of talk about how to best handle metaboxes going forward, and while this doesn't directly address that, I think it's worth considering expanding the Block metaphor to content that isn't necessarily
post_content
. There are many plugins and themes that declare custom post types where a freeform stack of blocks may not be appropriate, or might be used but as secondary descriptive content. The main content consists of multiple meta fields that the plugin will use to assemble it's template. In those situations, I would propose allowing for blocks to present that content and allow focusing into them to trigger their respective settings in the sidebar. Because these blocks are not optional to the post type, and should not be rearranged, they would not be deletable or movable. Because they aren't intended to be output in the content, they would have an alternate means of storage. Here's an example using Easy Digital Downloads.In this custom post type, the details about the Download make up the primary content. The post can't function without them so the block appears first. Because the plugin also supports descriptive text, the freeform block stack could still appear below it, but the initial download details block should NOT be a member of the
post_content
when it gets output. Rather, it should be a way to access post metadata. In this way, a content block is essentially acting to inform the user of the primary purpose of the post and give access to multiple metaboxes worth of settings fields. For reference, here's what a standard EDD post looks like today:Another example where a content block would be appropriate but not as part of the content output is The Events Calendar by Modern Tribe. In this situation the event details are the primary content of the post. The user should not be required to insert this necessary block to begin editing, and the plugin author shouldn't have to jump through any hoops to get to this data or delete the block from being output by
the_content()
. Its acting as a mechanism to inform the user and provide access to the available settings.I think we should consider a block to be an element that establishes the user experience apart from where or how it's backing data gets stored.
Like I said, this kind of block doesn't eliminate the need for "meta" UI. This is for content-focused post types. This probably wouldn't be appropriate for post types that have utilitarian UIs like form builders.
The text was updated successfully, but these errors were encountered: