-
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
Introduce concept of block templates for full site editing #17512
Comments
I'd say a separate post type and block for template parts makes sense. The design will probably differ a lot from reusable blocks so it will be better to keep the code separated early on.
See the patterns proposal: #17335. |
We may want to consider keeping track of which theme was active when a given |
Yes, a theme should provide an templates block data that get merged with When creating a |
I think this is definitely a good idea - regardless of the current content of a template part, the user should be able to choose the theme's default content for that area. I think users are often confused towards why the theme's screenshot or demo looks different from their site when they activate their theme, and this would help with that. Perhaps there could be a way for the user to choose, on theme activation, to use the default content from the theme.
What if a theme defines another content area for which the user doesn't have a template part yet? I can see a case for auto-populating the default content for that area in this case. |
Yes, in this case I believe the template part can be populated directly with data from the theme (e.g. in JSON), without needing to actually create a |
Since we already did some Full Site Editing work on WordPress.com, I’ll try to convey some of the things we’ve tried so far and some of our takeaways. I’d like to preface that with a comment that our work was intentionally scoped down for two reasons:
During our work we experimented with a couple of approaches:
We ended up using (3) in the end, because it seemed like the most seamless way to get what we need for our scoped-down solution. While this worked for us, it’s not necessarily the best long-term approach for Core, but some pieces could still be reused. This code now lives in:
Populating and storing template dataOur initial template data population happens on
In our case the benefit of (3) is that we don’t have to release a new theme version if we want to publish a fix or update to template data. As a result of (2) and (5), it’s possible to preserve existing customizations to template parts across theme switches. For example, if you want to just try out a couple of new themes on your site, and then revert to your original one, the previous theme specific customizations to your header would be restored. For storing the data, we are now only using
While all of the above can easily be worked around, they might hint that we are trying to clump together two conceptually different entities under the same roof, and we might discover additional work on account of that down the road too. It seems to me like the model would become much simpler if we enforced no nesting of entities of the same type, both for P.S.: I tried to condense this as much as possible, but it still turned out a bit longer than expected - sorry about that. :) If anything is unclear because of that I'd be happy to clarify. Also, if there is any way that we can further help the core FSE work based on what we currently have on WordPress.com (be it feature testing or user feedback) feel free to let me know. Kudos to @Copons for reviewing this and suggesting edits. ❤ |
Thanks for writing this up @vindl!
I think that a mixture of approach 1 and 2 would be optimal here. Themes should register template posts that hijack the hierarchy, but they should also be able to manually include them in PHP files. We're starting with a limited version of the former here: #17626, and of course the manual approach is always possible by including the CPT posts with custom code, but we might want to expose an explicit API for it in the future, although I also see value in just making the hijack the "supported" approach.
This is something we need to do as well.
I agree, this approach also makes the most sense to me. |
If I may chime in, as a person who worked hard on the WordPress.com Blank Theme experiment, and struggled immensely in explaining it to peers and stakeholders alike: we desperately need the best and clearest terminology we can come up with.
I don't have a good answer, and I know this seems like bikeshedding, but if we manage to figure out some unambiguous terms, then FSE will become 100% easier to discuss, and the project itself will move forward quicker. |
How about:
|
I think I was misunderstood: the meaning of each term is clear when you list them in a glossary. In the end, it was inevitable to me to alwayt add a bit of description and details every time I mentioned a |
We should just link to a glossary. |
Here are two more “templates”:
• The block template API against which blocks are validated. (I.e. inserted blocks can be required to match the global block template and some other block components include templates)
• Starter page templates: while not in core per se, this is the case where blocks are auto-populated into a page/block area.
A glossary will definitely be important, but I do agree with @Copons that unique terms for some of these would be very useful. As to what those could be though... 🤔🤔
…On Oct 22, 2019, 12:14 PM -0700, Enrique Piqueras ***@***.***>, wrote:
We should just link to a glossary.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Those are called block templates.
Those are now being called block patterns. Haha, yeah this will get confusing. |
A full page template can just be a pattern that gets applied automatically. Even if we decide to name them differently in the UI, I think they should share the same implementation. |
@vindl I like your template diagram. Is there any reason there is a Post Content Block in the middle of the page template? Why would that not just be another template part? So... a template is just a set of template parts. It seems reasonable as well that a template could be a combination of horizontal and vertical template parts (otherwise how would we get a sidebar!). Before we go down the slippery slope of non-differentiation between a complex block and a template-part...I would suggest that a template-part should be a theme-specific construct while the block is a theme-agnostic construct. There was also a related discussion in #18736 Thoughts? |
You might not want to introduce the overhead of a template part wrapper if you are not reusing the block/set of blocks in another template.
Definitely, I've been exploring grids as well, #18600.
Yeah, that's how it currently works. |
Cheers @epiqueras - the explanation is much appreciated. Sounds good. I concur with your comment about not needing a template part wrapper for non-reused blocks. The diagram above had made me concerned that the "post-content block" component was a hard-coded component rather than a sample "some block" as you explained above. So it sounds like a page can be all blocks, all template-parts or a combination of both...which is great. My compliments to the team. Looking forward to theming with the template-parts :-) |
Exactly! Glad I could help :-)
|
Thanks @timhibberd! Basically what Enrique already said. They can be both surfaced to users as Template Parts, however they are conceptually different in implementation detail in my opinion. Template Parts will be preserving their
That's true! I wanted to keep my example as simple as possible, so I left those out, but I didn't foresee any problems with incorporating them into the above model. My main intention was to represent the data relationships and the way they are stored. That Page Template in the diagram also has some resemblance to the actual layout, so I see how that could've been misleading. In any case, even in the above example, any (or both) of the Template Parts could be styled and presented visually as horizontal ones, turning that into a 2 (or 3) column page layout.
I'm not sure if I'm interpreting this part correctly and to which extent it should apply, but I think that this kind of separation could be useful. My addition of theme specific taxonomy terms in the diagram ( |
Cheers @vindl - much appreciated :-) I hope my comments came across as intended...to elicit clarifications (which you and Enrique did clarify nicely). I thought your proposal and diagram were spot-on. Regarding my comment about differentiation between a complex block and a template-part, I think you and Enrique have clarified that. My comment was intended to ensure that we can answer the question: "What is / are the difference(s) between a complex block and a template-part?". The definition of a "theme" in the Gutenberg era is still emerging and the answer to this question will, in part, help existing theme designers to make the mental shift from the old world to the new world. |
Most of the architecture work for this issue has already landed. I'm going to close this issue now, let's focus on smaller targetted issues now. |
we have launched a number of sites using wp_template custom post types. |
@JoshuaJarman you might want to start a new issue, instead of posting to a closed issue. |
@bph i'll try again. even mentioning the block templates and custom post_type wp_templates and its routing seems to confuse most people, so i hoped to ask in one of the few corners where people know anything about it. |
I responded on #24129 :) |
Based on ideas previously explored in #3588 (and PR #4659) and recently discussed via @mtias in https://make.wordpress.org/core/2019/09/05/defining-content-block-areas/ (see also particularly this comment by @westonruter), let's further specify how today's paradigm of hard-coded theme template files can transition to enable full-site editing using blocks.
There are two major technical pieces needed for this:
WP_Query
instance). This issue is focused on introducing said infrastructure.Based on these two pieces, several UI decisions need to be made on how to expose these features to the user, and we will likely need some iterations to get this right. While we'll out of necessity probably touch on some of those ideas here, I suggest we focus on finding a solid under-the-hood solution first.
Here's the concrete suggestion:
wp_template
, of which each post represents a single top-level template. In other words, a template that renders an entire page's markup (to be differentiated from so-called template parts)./*.php
template file to load. Basically, eachwp_template
post represents a specific one of those template files.<html>
,<head>
,wp_head
hook,<body>
opening and closing tag, etc.). Visually, it will render the actual blocks from the current template.add_theme_support()
, at least in a transitional phase.Based on this, a few further thoughts:
wp_template_part
, or an alternative variant of reusable blocks that only applies to template content (i.e. not individual post content, for better separation).index
,category
,singular
,single-product
, etc.) to the user because these are rather technical. While every theme developer has been exposed to them, they have (for a reason) never been used in WordPress UI. We will need to find a solid way for a user to understand which template they are editing, and for them to decide in which context/scope they'd like to edit the template. For an initial (experimental) implementation, it's fine to just expose block templates with these names.wp_template
post. Or it could include default block content (in place of today's template files) to use even if no user-created variant of that template exists as awp_template
post. Or on theme activation, thesewp_template
posts could be automatically created.custom-header
, widget areas, or nav menu locations probably don't make sense anymore. Other "features" like adding theme support fortitle-tag
could potentially be automatically enabled.The text was updated successfully, but these errors were encountered: