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

Site Editor Feature Request: See which templates use a given template part #42482

Open
jp-imagines opened this issue Jul 17, 2022 · 7 comments
Open
Labels
[Block] Template Part Affects the Template Parts Block [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") Needs Design Feedback Needs general design feedback. [Type] Enhancement A suggestion for improvement.

Comments

@jp-imagines
Copy link

What problem does this address?

On FSE/block themes, it's currently difficult to quickly determine which template parts are actively in use, or which templates use any given template part.

For example, if I want to update my site's header across all templates, and I have multiple custom header template parts available, I would need to either:

  • Manually check every template and update the "header" template part being used in each; or
  • Update every "header" template part, some of which may not be in use.

What is your proposed solution?

Within the Site Editor, possibly on the list of Template Parts, it would be great to see a full list of templates that use any given template part (if any). (Optionally, a similar list of all template parts being used on each template on the Templates list would provide similar helpful information.)

This would also make it much clearer that updating Template Part A would affect Templates X and Y.

Quick mock-up:
template part mockup

@talldan
Copy link
Contributor

talldan commented Jul 18, 2022

This would also be nice in a warning message when deleting a template part that's in use.

Code-wise, my understanding is that it would involve parsing the block content of every template and template part to find out which template parts are within them.

It'd be challenging and probably quite expensive to do.

@talldan talldan added [Type] Enhancement A suggestion for improvement. [Block] Template Part Affects the Template Parts Block [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") labels Jul 18, 2022
@Andrew-Starr
Copy link

I have a local plugin I created that does this. It is very helpful to see at a glance what template part is in use in which template.

The code is a bit rough but it basically parses the content of every template, then "flattens" the parsed content using the core _flatten_blocks function, and finally checks all the returned blocks to see if any have a blockName of core/template-part and returns an array of the found 'slug' 'attribute' for each part.

Repeat the above for template parts within template parts too.

I can't speak to how expensive it is but have not seen any noticable slow down doing this on my own local test install.

@Andrew-Starr
Copy link

I should also say that this is done in a separate admin page outside of the site editor for my own usage, and so if something like this was included in the site editor I do not know how resource intensive this would be and whether or not the site editor has the scalability for this.

@jameskoster
Copy link
Contributor

I agree this would be a useful enhancement. With all the work we're doing to better surface template part creation via patterns, it is easy for a proliferation of un-used template parts to occur.

@jameskoster jameskoster added the Needs Design Needs design efforts. label Jul 28, 2022
@jameskoster
Copy link
Contributor

One issue we might run into here is the significant visual noise when there are many templates. I do acknowledge there probably is some value in listing the templates, potentially even as links to go and edit them. Maybe we could do something like:

Screenshot 2022-07-29 at 12 31 21

Side note: It might be nice to do something similar for custom templates in the main template list:

Screenshot 2022-07-29 at 12 31 30

@jameskoster jameskoster added Needs Design Feedback Needs general design feedback. and removed Needs Design Needs design efforts. labels Jul 29, 2022
@annezazu
Copy link
Contributor

This was noted as part of the FSE Outreach Program's Site Editor Sneak Peek exploration:

When editing and saving a template part, it would be nice to know which templates each template part is included in. It wasn’t immediately clear that this would update any existing template that it is already used in (vs. making it available to be used for new templates)

@carolinan
Copy link
Contributor

How would this menu look when there is more than one item? For example the delete template action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Template Part Affects the Template Parts Block [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") Needs Design Feedback Needs general design feedback. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

6 participants