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

Request: Introduce the concept of an optional primary/principal/master template. #68884

Open
Andrew-Starr opened this issue Jan 25, 2025 · 1 comment
Labels
[Type] Enhancement A suggestion for improvement.

Comments

@Andrew-Starr
Copy link

What?
An optional primary template that rules over all other templates.
When enabled, the primary template would be requested first, and then other templates would be rendered within the primary template.

Why?
A couple of real world examples.

  1. So you want to make the header sticky, fixed to the top of the page. This is done by wrapping the header template part in a group block and setting the position of the group to sticky. To do this site-wide you need to go through every template and wrap the header in a sticky group. If you forget one template or introduce a new custom post type with a new template, you don't have a consistent design across the whole site. At some point you decide to no longer have a sticky header, again this involves editing every template to ungroup every instance of the header template part.

  2. A vertical side header. This can be accomplished by using columns (or a row or grid block perhaps) and then inserting the header template part in the first column (or second column if you want it right aligned), and you probably want to give the first column a defined width of say 300px or 20% for example. The content or query block would then go in the second column. Now you need to repeat this for every template. You then change the default font size or block spacing or you need the menu in the side header to accommodate more items and it becomes apparent that the side header width needs increasing or decreasing, so you need to go through each and every template making sure to give the column wrapper the same width.

If there was an optional primary template, both the scenarios above could be accomplished by adding the group/columns/row/grid layout in the primary template, and then there could be something like a template block which you would add in the remaining page space. This template block would then render the appropriate template, be it single, page, index, search results, 404, custom_post_type, custom_archive etc. The individual templates wouldn't need to contain the header, or the complex site wide layout, instead they would be freed up to concentrate on just what that template is needed for e.g. post content, query loop etc. There could even be an option at the template level to opt out of the primary template hierarchy if you wanted a particular template to break away from the site wide layout.

@Andrew-Starr Andrew-Starr added the [Type] Enhancement A suggestion for improvement. label Jan 25, 2025
@Andrew-Starr
Copy link
Author

Related discussion: #68418

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

1 participant