-
Notifications
You must be signed in to change notification settings - Fork 34
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
POC Use WordPress's new template mechanism #1594
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
planet-4
added a commit
to greenpeace/planet4-test-venus
that referenced
this pull request
Jan 26, 2022
/unhold 26863cb0-a676-4783-8218-355dfcc81d9d
planet-4
added a commit
to greenpeace/planet4-test-venus
that referenced
this pull request
Jan 26, 2022
/unhold d42767d1-94c2-4240-861b-425aacc4a090
Inwerpsel
changed the title
Allow inserting raw HTML in base template
Use WordPress's new template mechanism
Jan 26, 2022
Inwerpsel
changed the title
Use WordPress's new template mechanism
POC Use WordPress's new template mechanism
Jan 26, 2022
Test instance is ready 🚀🌑 venus | admin | blocks report | CircleCI | composer-local.json ⌚ 2022.02.11 15:05:16 |
planet-4
added a commit
to greenpeace/planet4-test-venus
that referenced
this pull request
Jan 27, 2022
/unhold 417fbc61-d9f2-4019-a5b3-54bc6a8b200f
planet-4
added a commit
to greenpeace/planet4-test-venus
that referenced
this pull request
Jan 27, 2022
/unhold 45a8d492-3264-40a7-b073-561f89001986
planet-4
added a commit
to greenpeace/planet4-test-venus
that referenced
this pull request
Jan 27, 2022
/unhold a3e61daf-2e6b-468c-8b57-4ae6a02aacd5
planet-4
added a commit
to greenpeace/planet4-test-venus
that referenced
this pull request
Jan 27, 2022
/unhold 8981ae35-4d86-4542-916e-9fc70127dafb
planet-4
added a commit
to greenpeace/planet4-test-venus
that referenced
this pull request
Jan 28, 2022
/unhold 7f67a908-c434-4c6f-82b3-1db9d2b31c4e
planet-4
added a commit
to greenpeace/planet4-test-venus
that referenced
this pull request
Jan 28, 2022
/unhold a5e59ba6-3334-4bf4-baa5-33b3f0eaceb6
Inwerpsel
force-pushed
the
add-some-templates
branch
from
January 28, 2022 15:00
c9d02dd
to
c1ba35a
Compare
planet-4
added a commit
to greenpeace/planet4-test-venus
that referenced
this pull request
Jan 28, 2022
/unhold 88f58466-3966-4c82-9840-611c7674be80
planet-4
added a commit
to greenpeace/planet4-test-venus
that referenced
this pull request
Jan 28, 2022
/unhold 0d8c34fb-da53-4a0f-994f-471dd69b20a6
Inwerpsel
force-pushed
the
add-some-templates
branch
from
February 9, 2022 14:37
ef11bb9
to
3adabd4
Compare
planet-4
added a commit
to greenpeace/planet4-test-venus
that referenced
this pull request
Feb 9, 2022
/unhold 0b2ecc23-8e3e-493c-a1b0-8ca097deb38c
* This way we can generate the inner HTML using core blocks and output it where it needs to be.
* First test with the new block-templates feature in WordPress. The naming is terrible so here's a full description: templates added to the block-templates directory are assigned by name to a certain type of dynamic content pages. * I created the page in the block editor and set the Query Loop block to use "inherit query from template". It's unclear exactly how things such as how many items per page need to be configured.
* The post title it gets on the author page is the author's latest post's title. This is because WordPress uses some weird global variables. * Instead for now I'll make it use the author bio block, which is the closest available.
* I might try to move some to template parts.
* Starting to look pretty close to the design.
* Almost identical to the author template, will move shared parts to template parts later.
* It's all the same.
Inwerpsel
force-pushed
the
add-some-templates
branch
from
February 11, 2022 14:54
3adabd4
to
3bb1698
Compare
planet-4
added a commit
to greenpeace/planet4-test-venus
that referenced
this pull request
Feb 11, 2022
/unhold 559e36c5-68b0-4472-8c14-a858cef330ba
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds an Author page template using a new template mechanism in WordPress. I hope one day each of these mechanisms will get a clear own name, but for now we need to explain in more detail to avoid confusion.
This mechanism works by checking the
block-templates
directory for a file with a certain name. For exampleauthor.html
for the Author page.It's checked before any of the other mechanisms, so I didn't have to remove
author.php
which it would use if we didn't provide this new file.There's just 1 problem, but a big one. We have a lot of elements of our site in Twig templates, in fact most of them. Ideally all of these should be converted to blocks so that we can just add those blocks to the new WP template files.
But that's a lot of work before we can start using this. To get around the limitation, I created a new "Framework" block which holds the entire Planet4 UI, except the content part. The content is created by rendering the block's inner blocks to a HTML string and output it raw in Twig.
This was surprisingly easy and could directly render the
base.twig
template with almost no modification.Observations
Test instance demo
I imported data from Denmark. Keep in mind that the author IDs on posts are not updated, so the author will change to whatever user has that ID on the test instance.
WordPress docs
Gutenberg repo related issues
Other WP themes that use this feature