-
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
An equivalent to "Inactive Widgets" for template parts #31397
Comments
Thinking more about this, the problem seems to stem from the way that two different concepts in the old theming paradigm are mapping to the same concept in the new paradigm. In the old paradigm:
In the new paradigm, the nuance seems to be lost. An easy "solution" to this problem is already possible, which is for the user to use reusable blocks when they add content to template parts. In this way, the reusable block effectively plays the role of the widget area. When they switch themes, they can just drop in these reusable blocks into their new theme. However, how many users would have the foresight to do this? Probably not many. Here is a proposal to solve the problem:
Tagging @youknowriad @Addison-Stavlo because I personally think template parts should be left out of 5.8 and not merged to core until this issue is resolved. |
I definitely agree and think we should take steps towards allowing all template part CPTs to be available from within the editor, regardless of what theme they were originally created with. However, I don't see how this would require drastically changing the implementation and using
Would that mean if I customized my header on |
I ended up using the existing post type after all when implementing the solution at #31971, so you can disregard the Regarding the endpoint returning results regardless of the theme term, I considered it, but settled on an alternative approach to let the endpoint accept a post ID instead. The main reasons are:
That's actually exactly what I meant, sorry if it was unclear. Although, there are actually three different ways this could be done with my proposal:
Although each might be appropriate for different situations, it might be better for the system to automatically select the best method behind the scenes, to avoid overwhelming users with options. |
I think the current approach would as well if we are only accessing file based templates corresponding to the currently active theme's directory.
How are we defining active here ("in use" or "able to use")? I would think 'active' means it is currently being used by a block somewhere, but it sounds like we would be marking it 'active' just to have the ability to use it - so by this definition it could be both 'active' but 'unused' at the same time? I may totally be missing something, apologies if so. But it still sounds like we could skip all the theme attachment complexity and just allow users access to customized template parts regardless of theme? It seems much more simple and manageable than updating slugs, ids, and/or theme mods every theme switch? |
You're right about this, and although it might seem like an extra layer of complexity, there are two reasons for it:
I appreciate the critique, it's the only way to know if the approach is viable. I certainly considered allowing the endpoint to accept different theme values, but it was applying the same kind of critique that led me to conclude it wouldn't work.
Theme mods overcome all of the above problems, and it mirrors exactly how themes handle widgets and menus. A menu doesn't forever continue referring to the theme that happened to be active when it was first created, menus in the active theme can't unexpectedly change because an inactive theme was deleted, and the same menu can be instantly moved in and out of the header of one theme and the footer of another. #31971 will make the same true of templates and template parts. Why risk a new and unproven mechanism for theme customisation when there is already a proven pattern to follow? |
Thanks for explaining @carlomanf! It sounds like a promising alternative. |
It looks like there is a new perspective on this issue now that 6.3 has started the process of merging template parts and patterns. The new "Patterns" section essentially is the equivalent of "Inactive Widgets," but I think there is still more work to do. One thing that strikes me as a little bit confusing is that when the user tries to create a new pattern, they have the option of creating either a template part or a pattern: I am not sure exactly why the user would choose to create a template part rather than a synced pattern. The main difference is synced patterns remain available after switching themes and template parts do not. Why would the user knowingly choose to impose this limitation on themselves? (Another difference is that template parts can be assigned to areas, but it seems to be more of a superficial difference that doesn't carry any behavioural implications.) Template parts seem like more of a mechanism for theme authors than for users. Am I missing something? It seems like it would mostly solve this issue to remove the "Create template part" option from an upcoming version of core and make it only available through the Create Block Theme plugin. Users would still be able to edit template parts provided by themes, just not create new ones. |
In many ways, template parts are considered the equivalent of widget areas. Through template parts, users who have the capability to
edit_theme_options
will be able to add blocks of content to their sidebars/headers/footers just like they added widgets to their widget areas.When a theme with widget areas is deactivated, the widgets that the user added will go into the Inactive Widgets section, enabling the user to transfer those widgets to their new theme easily.
When a theme with template parts is deactivated, the user's customised template parts become quite difficult to retrieve. They will not show up in the Site Editor at all, meaning that Appearance > Template Parts is the only way to retrieve them. Even then, they would have to open up two browser tabs to transfer their blocks to their new theme.
Clearly, there will be a need to be able to transfer template parts between themes in a more seamless way, like is possible with widgets. However, when a theme is not active, it is possible to delete that theme.
How can this be solved without risking content suddenly disappearing because of a theme being deleted, and also without denying users the freedom to delete old themes?
The text was updated successfully, but these errors were encountered: