-
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
Pattern / Template Part Unification - the technical challenges #57011
Comments
It is important to keep the HTML format because it allows anyone to create themes without knowing PHP. |
Other design details to consider:
|
The tough part is that there is still a role for template parts in themes, until they can ship with synced patterns at least. Otherwise one change will need to persist wherever a pattern is used (like blog views, post meta, or comments for example). |
I agree, but I don't know that the user needs to understand the difference between a "Template part" and a "Synced pattern". For all intents and purposes they're the same thing. Categorisation as a means of classifying things like headers/footers feels more intuitive. Stuff like post meta and comments are bit trickier... one short-term idea could be: "General" becomes a category under the patterns umbrella alongside headers/footers, ideally with a name that hints that they're for use within templates. That would mean themes could still supply them. |
Hi, I’m really interested in this subject. I’ve been thinking a lot about it. I’ve never contributed with code but now I’m writing a little plugin and designing a theme that I hope will someday be in the WordPress repo. In my opinion, all user customizations should be kept as user patterns, including the content of all template parts. I would only use template parts in the theme’s folder as a copy of the original design provided by the theme designer or developer. And would, as theme designer, provide the least amount of theme patterns (only the ones categorized as page or post templates). And then I would provide a complete set of user patterns in xml format for the user to import using the import tool, and a theme option to unregister all the theme patterns once the user has customized all of them (or only the ones he/she is going to use) by duplicating and creating hes / her own ones. The only thing I would do in the editor, is separate template parts from patterns in the site editor. Now the site editor has 5 parts (Navigation, Styles, Pages, Templates and Patters) and I would add ‘Template parts’. But would not try to unify both things, as Rich says, template parts still have a role. I would like to share what I’ve been doing in order to simplify things. This plugin explains a little bit: https://github.com/dballari/sahmi If you edit a template part like a footer, of any theme, and then create a synced pattern inside, with all the content of the template part, then you have an easy way to customize the footer. If you make a mistake, you can always recover the theme’s original code by resetting the template part. I’m currently designing a theme that will be delivered this way: with the xml content that turns all template parts into user synced patterns. It works and I thing is the best way to simplify things for the end user that does not know what a template part is. |
There's currently an issue where the Shortcode Block does not work in Synched Patterns in templates, but in template parts. We should keep an eye on that when changing the way these two concepts work in the future: #68214 |
Related #41717
With patterns and reusable blocks now mostly unified (albeit with some tidying up to do internally), it might be good to look at template parts and the technical challenges are present with undertaking a similar unification. This issue doesn't really consider whether it's a good idea to do this right now, but only what the challenges would be if we did.
A guiding principle would be to avoid making such a unification any harder in any future work undertaken on patterns and template parts. Generally it'd be future work moves towards aligning the two wherever the opportunity arises.
Here's a list (probably not exhaustive, additions are welcome) to consider:
Post types (
wp_template_part
andwp_block
) and server side codearea
while patterns can't, but it could be an optional feature of a pattern.origin
andsource
properties to indicate where they came from (theme, plugin). Patterns also havesource
(directory, user), so this aligns fairly well.isCustomized
attribute to indicate when a user has modified a theme provided template part. This would be something that's beneficial for patterns - see Patterns: allow overriding of theme patterns as well as duplication.category
and there's some alignment with the concept of anarea
, sinceheader
/footer
is also a category.theme
, though I don't know that this is a desired feature. It might be an opportunity to end this.Blocks (
wp:template-part
andwp:block
) and client side codearea
feature, header/footer areas should really have the<header>
/<footer>
wrapper.Extras
.php
files with some metadata, while template parts are plain.html
files. Patterns can also be exported from the UI asjson
files. There's likely to be some back compat concerns, but it might be good to pick one format as the preferred option..php
files support localization.Addendum - the
wp:pattern
blockThis block is a little bit of an outlier, it's not visible in the UI, but used by theme devs to incorporate patterns into templates. It could be deprecated and automatically migrated to a
wp:block
that performs the same task, but this is probably very low priority.The text was updated successfully, but these errors were encountered: