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

Update Appearance > Templates to list all templates #35994

Closed
jameskoster opened this issue Oct 27, 2021 · 39 comments · Fixed by #36379
Closed

Update Appearance > Templates to list all templates #35994

jameskoster opened this issue Oct 27, 2021 · 39 comments · Fixed by #36379
Assignees
Labels
[Feature] Template Editing Mode Related to the template editor available in the Block Editor [Status] In Progress Tracking issues with work in progress

Comments

@jameskoster
Copy link
Contributor

jameskoster commented Oct 27, 2021

At the moment Appearance > Templates only lists templates that have been created from scratch, or theme templates that have been customised by a user at the site.

It seems sensible to display all templates here, including those supplied by themes and plugins. Just like we do did in the Site Editor. This provides a convenient pathway for folks to go and edit all the templates in use at their site.

Since templates supplied by third parties cannot be edited, we may need to disable bulk actions for those templates.

@jameskoster jameskoster added [Feature] Full Site Editing [Feature] Template Editing Mode Related to the template editor available in the Block Editor labels Oct 27, 2021
@carolinan
Copy link
Contributor

I don't think this will make it easier for users, because this view is recognizable as a page where you perform specific actions.

What I mean is, the page looks the same as the list of post or pages, and having items on this list that are not editable is not expected.
Files from plugins and themes have never been presented in this view before.

@carolinan
Copy link
Contributor

carolinan commented Oct 27, 2021

I would actually prefer if this view was not changed in the plugin, and not ported to core in 5.9, because it adds to the cognitive load because there are just too many ways to edit templates and template parts.

  • Template editing mode
  • Site editor
  • Appearance menu -> templates or appearance -> template parts = block editor
  • HTML files (child themes for example)
  • Theme file editor

And for template parts, the isolated view is added to that list.

I won't even include the code editor mode since it is not (yet) implemented for templates.

@jameskoster
Copy link
Contributor Author

and having items on this list that are not editable is not expected.

But they are editable. Or to be precise, folks are able to customise them, and subsequently revert their customisations. But I don't think we need to surface that technicality here. As far as the end user is concerned, they are editing the template. FWIW this is exactly how it is implemented in the Site Editor currently.

Site editor

It seems highly unlikely this will be included in 5.9 in its current state.

HTML files
Theme file editor

The average user will very rarely touch these. You can even make the case that the block-based template editor supplants the theme file editor entirely.

@Aljullu
Copy link
Contributor

Aljullu commented Nov 8, 2021

I wanted to highlight that this is something that is affecting us as we are preparing WC for WP 5.9 and FSE editing. Until now, we worked on making WooCommerce templates (ie: Single product, Product archive, etc.) available from the Site Editor, so users could modify them from there (see woocommerce/woocommerce-blocks#5062).

Since #36194, however, that's no longer possible and there is no other way to modify templates added by plugins. Listing all of them in Appearance > Templates would solve this, assuming the same functions/hooks will be used.

@jameskoster do you know if that's something that is tracked for inclusion in WP 5.9? Is there anything we can do to help to move this forward from our side? If not, is there any other recommended way for plugins to add templates that can be modified?

@jameskoster
Copy link
Contributor Author

jameskoster commented Nov 8, 2021

@Aljullu Yup, this should be included in 5.9 :)

Edit: That said, I don't think it has been assigned to anyone yet (maybe @kevin940726 ? 🤔), so if y'all have the bandwidth, I'm sure any help would be appreciated!

@kevin940726
Copy link
Member

I've looked into this, but unfortunately I'm still not sure how to fix this. Perhaps would be easier for PHP/WP experts to take this ;)

@carolinan
Copy link
Contributor

carolinan commented Nov 9, 2021

While referring to this issue and trying to find a developer to work on it, I was notified that the issue is not well documented, and I was asked to link to the decision about why the screen needs to show the different types of templates.

I am not sure what to point to other than the design proposals in #29630

I'll link to this PR as well if it helps add context #36194

@kevin940726 Do you want to include a summary about what you tried that did not work?

@jameskoster
Copy link
Contributor Author

In addition to the links you provided I would say: if we don't list all templates here then it will not be possible for users to customize templates that are added by themes or plugins in 5.9. They will only be able to create (and edit) templates from-scratch, which seems like a shame.

I believe @Aljullu is looking in to working on this. I don't know if you want to assign this issue Albert?

@jameskoster
Copy link
Contributor Author

jameskoster commented Nov 9, 2021

One more thought one this one, for unedited templates that are supplied by themes and plugins, we might consider updating the action to read "Customize" rather than "Edit".

Screenshot 2021-11-09 at 16 18 13

This could help users better understand that they're customizing rather than editing the raw template.

@Aljullu
Copy link
Contributor

Aljullu commented Nov 9, 2021

I believe @Aljullu is looking in to working on this. I don't know if you want to assign this issue Albert?

@tjcafferkey @dinhtungdu are interested on working on it. For some reason I'm unable to assign the issue to them (and they can't assign it either).

@kevin940726
Copy link
Member

I tried looking into the source and couldn't find a way to extend the default list. I'm definitely missing something, but I don't have time to dig into it deeper 😅.

@tjcafferkey
Copy link
Contributor

Me and @dinhtungdu have been looking into this issue over the past day or so and have not come up with a suitable solution. Fundamentally the templates in this screen are being treated like they are for every other post type using the WP_List_Table. This means:

  • Its data is being stored and loaded from the database only.
  • They remain in the database and are presented to the user regardless of whether they’re relevant anymore.
  • There’s no hooks available for us to access this data.

And because of this, it also means:

  • We can’t load in templates from the filesystem (ie. from plugins or themes).
  • We will be showing templates from plugins or themes that have been switched, deactivated or deleted. These may no longer be relevant to the user, but because they’re still in the database it means they’re still getting rendered in the Templates screen.

There were a number of workarounds we considered which included creating database entries which were just references to files in the filesystem, however these felt very much like hacks and came with complexities of their own. Seeing as this is a problem all theme and plugin developers are going to have we didn’t want to set a precedence which was fundamentally a workaround or not officially supported.

It seems as though we need a solution which behaved like the recently removed Site Editor navigation where:

  • We can combine data from different sources (database, filesystem etc).
  • We can show the user templates which are currently relevant to their site (only related to active themes/plugins).

Because of the points mentioned above, I can’t think of an approach which would be suitable not only for WooCommerce but also every other plugin or theme out there which will want to use this feature and I am wondering whether the current approach needs a re-think, or whether we’ve just missed something in the current implementation which supports our needs.

@Mamaduka
Copy link
Member

Thanks for the excellent summary, @tjcafferkey.

One alternative I can think of is to:

  1. Disable default post-type UI.
  2. Replace it with a custom dashboard page, say - wp-admin/themes.php?page=templates
  3. Extend WP_List_Table
  4. Use get_block_templates for fetching items.

@dinhtungdu
Copy link
Contributor

dinhtungdu commented Nov 10, 2021

@Mamaduka thanks for sharing the alternative, we considered the approach you mentioned but we haven't found the solution for pagination that approach introduces. If you have any idea to solve that issue, please let us know.

By the way, did you mean gutenberg_get_block_templates() instead? The get_block_templates() only return the wp_template posts, not the templates from files. Edit: get_block_templates() was updated in the WordPress trunk

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Nov 10, 2021
@kevin940726
Copy link
Member

It seems like we can't do much in the WP admin style list. If it's too tricky to do then I don't think it'd be worth it. I created #36379 as an alternative to implement the list from scratch. It also matches the ultimate design we had in #29630 (comment).

@Mamaduka
Copy link
Member

@dinhtungdu The get_block_templates doesn't support pagination, so I don't think we can do much here at this point.

We can fake pagination by slicing results, but this still means we fetch every template. So I think it's okay to ignore it v1; we don't have data on how many templates sites might have.

@kevin940726 building SPA will probably be more time-consuming than using a custom WP_List_Table. @dinhtungdu and @tjcafferkey, what do you think?

@tjcafferkey
Copy link
Contributor

We can fake pagination by slicing results, but this still means we fetch every template. So I think it's okay to ignore it v1; we don't have data on how many templates sites might have.

As long as we're only returning the results that are related to the site in its current state (ie not returning templates from deactivated themes or plugins) then I agree, I can't imagine there being lots of templates either.

building SPA will probably be more time-consuming than using a custom WP_List_Table. @dinhtungdu and @tjcafferkey, what do you think?

I'm not super familiar with all the code involved, but I'd imagine building a SPA from scratch would be more time consuming. @dinhtungdu would you agree?

@kevin940726
Copy link
Member

I don't think we have to build a traditional SPA from scratch. We can just start by implementing client side router, so that we don't have to reload the page over and over again when we're inside the site editor. It will also paves the way for future improvements, as I believe SPA is a much better architecture for the site editor.

@shadigaafar
Copy link

One more thought one this one, for unedited templates that are supplied by themes and plugins, we might consider updating the action to read "Customize" rather than "Edit".

Screenshot 2021-11-09 at 16 18 13

This could help users better understand that they're customizing rather than editing the raw template.

you will also need a way, to remove all customization.

@jameskoster
Copy link
Contributor Author

you will also need a way, to remove all customization.

This is possible whilst editing the template:

Screenshot 2021-11-12 at 15 16 24

But I agree it would be a handy affordance here as well.

@ndiego
Copy link
Member

ndiego commented Nov 12, 2021

I am late to the party here, but I am confused how I edit a template now in 11.9. If I do a fresh install of WordPress, Gutenberg 11.9 and TT2, how would I, for example, go about editing the 404 page template supplied by the theme? Because the template file has not yet been edited by me, it does not display in Appearance > Templates.

@ellenbauer
Copy link

Hi there, I'm a bit confused right now as well. I always thought it's super helpful FSE feature for users to have a nice overview of all the available templates a theme or plugin provides. Will this be added again once FSE is further along?

@ellenbauer
Copy link

@ndiego From what I've gathered the overview list of all templates is gone right now, but users are still able to edit a template when they chose it for a page (Page Sidebar settings/Template: Choose your template has the option 'Edit').

@carolinan
Copy link
Contributor

That list only includes the page templates not 404, search, archive etc.

@jamiemarsland
Copy link

Hi, confused here also. The only template it looks like I can edit is the index. All others have gone (unless I edit from the page, or post - which seems an odd place to locate?

template editing
)

@Denis74F
Copy link

Hi,
I completely agree. The only procedure I found to modify a page template was this:
I create a new contact page with a "contact" template
I set this page as my homepage
now I can edit it from the full site editor
It is too complex a procedure, also considering that if I have particular templates for posts, what can I do?

In my opinion the templates should appear in a list when the customer publishes a page or a post with a certain template, giving the possibility to modify them.
Otherwise it makes no sense to have them and we proceed only with the Patterns, which however is not the same thing, that is, it is much more limited.

I am creating a theme using the template part function a lot, because it makes the theme very customizable by replacing, for example, one Header rather than another and so on.However, in many layouts I have given the possibility to customize it 100% through the editor of the complete site, but if this feature is no longer available I would have to review the whole project.

@ndiego
Copy link
Member

ndiego commented Nov 13, 2021

I presume this change was made because complete FSE is not coming to 5.9. And I understand why 5.9 should not have it. That said, I propose this change (the Site Editor sidebar being removed) be reverted in Gutenberg specifically asap for all the developers currently working on FSE. Once a suitable replacement is built, then it can be removed/updated as originally planned. The current setup makes it extremely challenging to built and test a FSE theme. Personally I have a demo site reverted to 11.8.2 just for that purpose.

@jamiemarsland
Copy link

I agree with Nick

@tinjure20
Copy link

Suggestion from DYI WordPress User

To mitigate concerns that users messing up with FSE template editing features, these theming tools could be linked to the user's role.

Yet, a new Theme Author user category (equivalent of admin) could be created and assign FSE theme authoring tools to theme authors only; auto disable them through config.php file.

@jameskoster
Copy link
Contributor Author

Hi there, I'm a bit confused right now as well. I always thought it's super helpful FSE feature for users to have a nice overview of all the available templates a theme or plugin provides. Will this be added again once FSE is further along?

There are details of how it will be added again in the OP :)

That said, I propose this change (the Site Editor sidebar being removed) be reverted in Gutenberg specifically asap for all the developers currently working on FSE.

You can still access the Site Editor via Appearance > Editor.

@Denis74F
Copy link

You can still access the Site Editor via Appearance > Editor.

Yes, but you cannot edit the templates.

@jameskoster
Copy link
Contributor Author

Yes, but you cannot edit the templates.

Right. That is why we're updating Appearance > Templates to list all templates, as outlined in the OP.

@shadigaafar
Copy link

I presume this change was made because complete FSE is not coming to 5.9. And I understand why 5.9 should not have it. That said, I propose this change (the Site Editor sidebar being removed) be reverted in Gutenberg specifically asap for all the developers currently working on FSE. Once a suitable replacement is built, then it can be removed/updated as originally planned. The current setup makes it extremely challenging to built and test a FSE theme. Personally I have a demo site reverted to 11.8.2 just for that purpose.

I agree, asap.

@shadigaafar
Copy link

shadigaafar commented Nov 15, 2021

Yes, but you cannot edit the templates.

Right. That is why we're updating Appearance > Templates to list all templates, as outlined in the OP.

it should not be removed from first. you don't remove something very important unless the replacement is ready.

@carlomanf
Copy link

I presume this change was made because complete FSE is not coming to 5.9. And I understand why 5.9 should not have it. That said, I propose this change (the Site Editor sidebar being removed) be reverted in Gutenberg specifically asap for all the developers currently working on FSE.

it should not be removed from first. you don't remove something very important unless the replacement is ready.

I agree with these sentiments. Removing features from the plugin because they are not ready for core does not make sense. If they are not ready for core, then why not just leave them out of core but leave them in the plugin?

@ellenbauer
Copy link

So by now I understand that this all default templates will be added to the Appearance/Templates list as a solution to the current issue that templates can't be edited as we were used to from the Site Editor menu.

I think many of us how have started to build for FSE are a bit confused that the Site Editor experience has changed quite significantly after being introduced already. I also don't really understand why the Site Editor menu had to be taken out of the Gutenberg plugin.

Going forward is there some form of documentation on how the Site editor will evolve from here? Will the Site Editor menu (I mean the left-aligned dark menu) be added again? Or what will happen with it?

@Otto42
Copy link
Member

Otto42 commented Nov 15, 2021

Perhaps adding in something to the Add New button for templates would make the most sense. I spent nearly an hour trying to use that button to add a "Category" template today, fiddling with the slug, the naming, etc, to no avail.

I did figure a way to edit, for example, the 404 template properly, but only because that was a template in 2022 already, and the way I used through the Page editor is nonsensical.

If the default list item table needs adjustments, then it's okay to adjust it to fit the purpose. Right now, FSE simply doesn't work because there's no actual way to even start editing templates other than "index".

@noisysocks
Copy link
Member

Just a note that we've restored the W menu in Gutenberg 11.9.1. This fixes the immediate problem people are having which is that they can't edit templates when running WordPress 5.8 + Gutenberg 11.9.

We're still exploring removing the W menu in favour of Appearance → Templates, etc. This will be a part of Gutenberg 12.0 and WordPress 5.9.

@jameskoster
Copy link
Contributor Author

Thanks to #36516 it will be possible to edit templates once again in Gutenberg 11.9.1. And when #36379 is merged for 5.9 the Appearance > Templates view will no longer exists. I therefore think it is safe to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Template Editing Mode Related to the template editor available in the Block Editor [Status] In Progress Tracking issues with work in progress
Projects
None yet