-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Allow usage of block based "template parts" without using block based "templates" #37943
Comments
@priethor just wanted to put this on your radar as this might be another great idea to consider for gradual adoption measures. |
This is precisely what the universal themes exploration was doing on the side. You'd end up with It's something we could formalize into a core API (i.e. |
@mtias is there a ticket where the discussion around how coupled a template part is to a theme is being tracked? Would love to link it here to ensure we have a clear understanding of the dependencies. |
In WP 5.9 we already added 3 new functions to do these things: |
@aristath That is very cool! Thanks for sharing :) So the main thing that this ticket is asking then is whether we can activate the site editor for template parts alone without needing to enable full on templates |
@fabiankaegy yes, correct, we are missing the ability to enter the site editor in the "focused template part" mode directly. We have the building pieces mostly in place, we just need to enable it for classic themes. It should be a good area of work for 6.0. A classic theme should not need to use full block templates to benefit from block template parts and a UI to manage them. The things to consider are mostly around the information architecture and access points. |
I agree that this would be an excellent stepping stone between classic themes and FSE and it's something my team is looking for. In the meantime, we're using a custom post type as a stop-gap solution, which presents its own challenges. |
It seems we need some more documentation on how to use these from a PHP template. |
Fabian's proposed suite of features for a template-part-first adoption of Full Site Editing is the one thing I'm most excited about in WP's near future. I understand v6 is now in feature freeze, but I haven't yet seen any work towards this:
My current experience of adding an The block editor is amazing in many ways, but I can't get fully behind it when I feel it's removing things I enjoy having. I would love the ability to give content editors controlled "block editor windows" into their sites in the context of classic templating 👍 |
This exactly. It at least would make adopting FSE easier than an all-at-once or all-or-nothing approach. The Appearance > Editor screen would be great to have for just template parts and global styles, while still allowing templates themselves to be in PHP. |
This is a great idea that will help the move from classic themes to FSE. Been thinking how this can be implemented to support the intended use, and to discourage "overuse", deep-nesting, and similar. Can easily see a classic theme that would use blocks in a hard-coded template part for the header, footer or sidebar. Thinking this would work and look great. That basically means the "widgets" in these areas are now native blocks with no restrictions! On the other hand thinking that this should be limited to specific areas: header, footer, sidebar(s), main content. Nesting of hard-coded template parts may turn out to be pretty hard to support and maintain. Imagine having to support deep-nested blocks styles/CSS that may be changing from time to time, or scripts that are connected to or depend on specific blocks. |
Related: #41119 |
The biggest challenge here is going to be how to give access to an interface for editing these parts. I think the most straightforward approach would to add a "Templates" item under Appearance on non-block themes when they make use of parts.
It'd be good to map a quick design flow on how it might work. |
I assume a scan of the HTML files in |
The files scan is only performed when the site editor is loaded. To expose the UI in the admin menu, a more lightweight check would be needed, since it needs to run on every admin page load. I think |
Could the existing
All of this functionality would be so much more useful with a way to restrict top-level blocks to the intention of the template part. Something like:
|
Sharing a quick flow for this appoach: If we wanted to provide a way for users to set/change template parts from the post editor, a “Templates” panel could be added to the document settings tab for specifying what template part should appear in a particular area: Would still need to think through how a change could be saved in that case (which would normally be saved to the Template) but wanted to check in to see if this aligns with what folks have in mind so far! |
Hi, folks I decided to share my current progress for this feature - #42729. All feedback is welcome ❤️ |
As a follow-up for this feature itself I've also created a new issue to add the ability to lock the root level of a template part #42775 |
Resharing a few high level thoughts from the conversation of a related PR:
There is some potential for user confusion:
In both cases, there may not be a ton we can do, but it might also not be a big problem in practice. If it turns out to be, we could follow up with a minimal welcome-modal that explains the feature, just like the welcome modal for the site editor does. |
@Mamaduka how are you feeling about this work considering your WIP PR? Trying to check in ahead of feature freeze for 6.1 and this would be awesome to have progress on. |
Honestly, if possible I'd be delighted for this to only be enabled in the next version as a "A plugin can opt in to the UI and create its own links to its defined template part" -- without having core create the menu ui that could lead to the confusion referenced? I'm much more interested in having this be something plugins and the like can opt in to a limited functionality of, and am 100% comfortable with saying they then need to define the UI routes to get to that page. They may want to add a link to it as a subpage on a custom post type instead of the Appearance menu, for example. |
What about customizing the Author bio box and the Comments section in a Classic theme? Perhaps these elements in some way could also be added into a kind of template area in Classic themes... Currently one would need in a Classic theme to go to a post and create a new page template and add the blocks there. One would need to remember to switch from the default page template to the custom page template for every post. |
@paaljoachim These are exactly the things that I was thinking about for this. There are areas in classic themes that can benefit from block customizability. And currently, the jump to full-on block-based themes is too drastic. Therefore it would be great to be able to edit just parts of the website (template parts) using blocks :) |
@georgestephanis I can see your point and think the idea of allowing developers to link directly to the template parts editor for a specific template part is really cool. That could definitely be an interesting exploration. I personally think though that it would be more confusing than the template parts menu under appearance which brings you to the site editor template part list view. With that we have some more consistency with how it works in the other editors and also we expose all the various available template parts to the user. Which makes them much easier to discover. Also, I think that since this feature is really primarily intended for themes (since it gets enabled via a theme supports flag and themes are where you ship the template parts) it should not rely on custom work done in plugins or a lot of custom PHP work to manually create the UI for the links to the template part editor. Finally, I think that it would lead to a confusing experience if every theme would expose these links slightly differently. It would make switching themes even more confusing since the way you edit template parts works completely differently. |
@annezazu, PR is primarily stable. I need to do small follow-ups, but that's it. We can land the new Welcome modal, suggested by @jasmussen, separately. @georgestephanis, I agree with Fabian that this feature shouldn't rely on 3rd-party plugins to expose UI. |
Awesome! Great work, @Mamaduka. As we spoke about via DM, let's get a call for testing in place asap when this lands. |
Not sure whether this comment is better placed here or at #42729, but I will put it here in case more people see it. A potential issue with the implementation of #42729 is that a theme might support both template parts and widget areas, meaning that both the Template Parts and Widgets submenu items are added to the Appearance menu. In this case, I expect it would be quite unclear to the average user why there would be two different destinations with very different interface designs, when both features apparently have the exact same purpose. Both support the inclusion of blocks, and both are rendered by the theme using a template tag. Whether the template tag is There is already a consensus at #39270 that template parts will be the supplanter of legacy widget areas, but is more from the perspective of block themes that did not otherwise support widget areas. Allowing both to co-exist with noticeably different interface designs does not seem like a good outcome. |
@carlomanf I agree that having both at the same time is not the best experience. I personally think of the two a bit different because in my opinion template parts are more powerful than widget areas since they conceptually give you more control over the layout of a section. (I know technically speaking you could do very similar things in block-based widget areas) Since template parts are clearly the way of the future, and since this template part editor is opt-in only, I am of the opinion that this confusion isn't going to be a problem. And that we would limit ourselves if we would cut off the support for the more powerful template parts in classic and hybrid themes. Having access to template parts in these themes is a great pathway for adopting more full site editing capabilities without having to jump all in. |
I think there are ways to lessen the confusion between template parts and widget areas without cutting off support for both at the same time.
|
I am not totally sure that this issue should be closed, as it feels like a good place to discuss various solutions. @Mamaduka George has one PR that has now been merged, but there might be a few more that also needs to be created. I will reopen this issue. Let's keep discussing and continue iterating on solutions that come up. |
This should be closed for project tracking purposes as the main implementation is merged. Let's open follow ups to narrow down experience gaps or improvements. @carlomanf I think that's a great point. It's also true generally for customizer / site editor or customizer / styles. The semantic space is generally the same between widget areas and template parts. We had on the backlog the idea of introducing a "sidebar" area next to "header" and "footer" which would increase that overlap. Another point of reference is how when you use the post editor you don't need to choose, from a user perspective, different entry points for blocks or classic editing. It generally just works depending on how the site and content is configured. Ideally all the phase 2 tools would also work in a similar way. |
@mrleemon, I saw that comment this morning. It looks like the shortcodes issue was missed when the |
What problem does this address?
Jumping all in on Block Based Themes can be quite difficult & disruptive. Especially on a legacy theme that has loads of customizations that currently are not feasible within a block based theme. There may be new areas of the site though or specific areas of the site where it would be interesting to use the new tools to build just a part of the theme in a block based manner.
Like for example a site that wants to build just the site footer using a block based template part.
What is your proposed solution?
Allow the usage of block based "template parts" without having to also allow block based "templates". In that case the "Editor" (previously Site Editor) would only display the "Template Parts" and not allow the creation of "Templates". And in the themes traditional
footer.php
file the theme author could render the block template part like so:In an ideal case theme authors would also be able to filter whether or not editors should be allowed to manually create their own "template parts" or whether only the ones provided by a theme are available.
Providing this template part first approach to adopting FSE would open the door to many more use cases that currently are not jet ready to jump all with their full content.
Note: This conversation was started in the #fse-outreach-experiment channel in the WordPress Slack
The text was updated successfully, but these errors were encountered: