Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Improve the default template provided to the post/page template editor #177

Closed
carolinan opened this issue Oct 29, 2021 · 9 comments
Closed
Labels
Milestone

Comments

@carolinan
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
When you create a new template (for example from the block editor Template Section),
the Gutenberg default template is used which uses 3 groups, a site title, tagline, separator, post title and content.

Describe the solution you'd like
A nicer looking default template could be added.

@jffng jffng added the [Type] Enhancement New feature or request label Oct 29, 2021
@kjellr
Copy link
Collaborator

kjellr commented Oct 29, 2021

This seems like something that should just happen automatically for block themes. If you choose "New", then Gutenberg should provide you with a copy of your current template to edit.

I did try just mapping this to one of our existing templates using the function provided here:

/**
 * Add a default block template.
 */
function twentytwentytwo_default_block_template() {
	add_filter( 'block_editor_settings_all',
		function( $settings ) {
			$settings['defaultBlockTemplate'] = file_get_contents( get_theme_file_path( 'block-templates/single.html' ) );
			return $settings;
		}
	);
}
add_action( 'after_setup_theme', 'twentytwentytwo_default_block_template', 0 );

... but it didn't render any of the theme's template parts. 😞

Screen Shot 2021-10-29 at 10 29 14 AM

If a theme did want to provide an alternate default template, it seems like that should happen in theme.json, rather than in functions.php.

@kjellr kjellr changed the title Improve the default template Improve the default template provided to the post/page template editor Oct 29, 2021
@kjellr
Copy link
Collaborator

kjellr commented Oct 29, 2021

Opened two Gutenberg issues for that:

WordPress/gutenberg#36086
WordPress/gutenberg#36085

If someone can help me figure out whether the template part loading issue is something we can fix here or not, that would be great. I'm unclear if that should be an upstream issue.

@jffng
Copy link
Collaborator

jffng commented Oct 29, 2021

I'm unclear if that should be an upstream issue.

I think this should be filed upstream as a bug — the template parts are accessible when you enter template editing mode, so they should also be via the default template.

I tried various hooks / loading orders to see if it was an issue that could be solved by loading priority, and could not get the template parts to load in any combination.

@kjellr kjellr added this to the Beta 1 milestone Oct 29, 2021
@kjellr
Copy link
Collaborator

kjellr commented Nov 1, 2021

Thanks — I've opened a new Gutenberg issue for this: WordPress/gutenberg#36124

@carolinan
Copy link
Collaborator Author

And can this be solved by adding the actual markup instead of including the existing file?
If it can, I would not consider this a big but an optimization.

@carolinan
Copy link
Collaborator Author

carolinan commented Nov 11, 2021

Can I ask for a decision about how long to wait for an upstream solution before I add a pull request to the theme?
An upstream solution seems unlikely because it is not a bug, and because of the time frame; and because the issue has not been listed as a 5.9 must have.

@kjellr
Copy link
Collaborator

kjellr commented Nov 12, 2021

And can this be solved by adding the actual markup instead of including the existing file?
If it can, I would not consider this a big but an optimization.

I don't think it can. It's important to allow the header and footer pull from the actual template parts, so that they stay in sync. I think it would be unexpected and confusing to have these look the same as the original templates, but not to stay in sync with template part changes.

A resolution to WordPress/gutenberg#36124 would fix that, and I think that's all we need to get this working in the theme (I do consider that issue to be a bug, so I think a fix for 5.9 is reasonable if it's technically doable). There's a potential workaround there that I'd love folks' input on. If that's not viable we can try and get a more thorough fix prioritized.

@kjellr kjellr modified the milestones: Beta 1, Beta 2 Nov 12, 2021
@kjellr kjellr modified the milestones: Beta 2, Beta 3, Beta 4 (Tentative) Dec 7, 2021
@kjellr
Copy link
Collaborator

kjellr commented Jan 10, 2022

I'm moving this to a post-launch milestone since WordPress/gutenberg#36124 is no longer going to be part of 5.9. We'll migrate this issue over to Trac around the time that 5.9 launches and continue tracking there.

@kjellr
Copy link
Collaborator

kjellr commented Jan 26, 2022

This has been migrated over to Trac here: https://core.trac.wordpress.org/ticket/54930

@kjellr kjellr closed this as completed Jan 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants