Skip to content
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

Template Bugs (specifically when locking blocks) #5521

Closed
jasonbahl opened this issue Mar 9, 2018 · 4 comments
Closed

Template Bugs (specifically when locking blocks) #5521

jasonbahl opened this issue Mar 9, 2018 · 4 comments
Labels
[Feature] Templates API Related to API powering block template functionality in the Site Editor [Status] Needs More Info Follow-up required in order to be actionable.

Comments

@jasonbahl
Copy link

Hello!

I'm using Gutenberg 2.3.0 on WordPress 4.9.4 and I'm trying to work with Gutenberg templates and I'm running into issues/bugs.

I recorded a video of my experience which you can see here for reference (https://youtu.be/09vukEJn8kc), but I'll also outline my experience below.

My goal was to move some pieces of the editing experience from Meta Boxes to Blocks, and I thought Templates would help with that quite a bit by having some "fixed" blocks, then some "flexible" blocks, then some more "fixed" blocks, to provide a more cohesive experience for editing the page (much like what @mtias demoed at WordCamp US).

This screenshot captures my goal. Where the grey blocks would all be "locked" in place, but the blue block would be a container block allowing for flexible input of other blocks.

screen shot 2018-03-08 at 1 56 27 pm

To do this, I used some code I found on the documentation site, with some changes to get the blocks I was after:

function myplugin_register_book_post_type() {
	$args = array(
		'public' => true,
		'label'  => 'Books',
		'show_in_rest' => true,
		'template' => array(
			array( 'core/paragraph', array(
				'placeholder' => 'Article Description',
			) ),
			array( 'core/heading', array(
				'placeholder' => 'Author Name',
			) ),
			array( 'core/paragraph', array(
				'placeholder' => 'Author Email',
			) ),

			array( 'core/columns', array(), array(
				array( 'core/image', array( 'layout' => 'column-1' ) ),
				array( 'core/paragraph', array(
					'placeholder' => 'Add a inner paragraph',
					'layout' => 'column-1'
				) ),
			) ),
			array( 'core/heading', array(
				'placeholder' => 'Call to Action',
			) ),
			array( 'core/button', array(
				'placeholder' => 'Action Link',
			) ),
			array( 'core/heading', array(
				'placeholder' => 'Author Name',
			) ),
			array( 'core/paragraph', array(
				'placeholder' => 'Author Bio',
			) ),
		),
		'template_lock' => 'all'
	);
	register_post_type( 'book', $args );
}
add_action( 'init', 'myplugin_register_book_post_type' );

At first, this appears to provide more or less what I was after. I wasn't able to figure out how to make the "columns" default to 1 column (just be a regular container?), and I couldn't figure out how to define what blocks should be allowed to be added to that container 🤔 (just incomplete docs? or possibly an in-progress feature?)

The real weird stuff seems to be around locking blocks. With blocks locked, there are places in the whitespace that can be clicked to add a new paragraph block that cannot be removed if blocks are locked. I show that pretty well in the video starting at ~4:40.

I think there's a lot of potential with templates and nested blocks. Hoping to see this stuff worked out!

Screenshots / Video

https://youtu.be/09vukEJn8kc

@jasonbahl jasonbahl changed the title Template Bugs Template Bugs (spefically when locking blocks) Mar 9, 2018
@Soean Soean added the [Feature] Templates API Related to API powering block template functionality in the Site Editor label Mar 9, 2018
@markjaquith markjaquith changed the title Template Bugs (spefically when locking blocks) Template Bugs (specifically when locking blocks) Mar 10, 2018
@jasonbahl
Copy link
Author

Sounds like #5574 might fix the primary issue here (inserting blocks when the template is locked).

I'm still curious how to go about defining a list of components that can be added to a container component (is this possible, just not documented, or not yet possible?)

And also curious if it's possible to have a single-column container - I've seen #4900 which is essentially what I'm looking for. . .not sure if there's a way to do that yet or not.

@youknowriad
Copy link
Contributor

Templates went through several iterations and I'm not certain what's left actionable in this issue. Would you mind clarifying?

@youknowriad youknowriad added the [Status] Needs More Info Follow-up required in order to be actionable. label Nov 26, 2018
@jasonbahl
Copy link
Author

@youknowriad I'll check things out and report back. Thanks!

@designsimply
Copy link
Member

Closing while we wait for more info. @jasonbahl can you please re-open if there are still actionable issues here or please feel free to open new issues if that will be easier. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Templates API Related to API powering block template functionality in the Site Editor [Status] Needs More Info Follow-up required in order to be actionable.
Projects
None yet
Development

No branches or pull requests

4 participants