Refactor workshop template to increase flexibility #195
Labels
[Component] Content
Website development issues related to the content on Learn.
[Component] Learn Plugin
Website development issues related to the Learn plugin.
[Component] Learn Theme
Website development issues related to the Learn theme.
[Type] Enhancement
New feature request for the Learn website.
Background
#186 will require some changes to the block template, to add new elements to the page. Currently, the template is hardcoded in
post_content
via thetemplate
assigned to the CPT.https://github.com/WordPress/learn/blob/beacb50998a874fc5f90dd134074c8a59f9b313c/wp-content/plugins/wporg-learn/inc/post-type.php#L142
The template has some "primary" user-generated content like paragraphs/lists describing Learning Outcomes and Comprehension Questions...
https://github.com/WordPress/learn/blob/beacb50998a874fc5f90dd134074c8a59f9b313c/wp-content/plugins/wporg-learn/inc/post-type.php#L169-L207
...and "secondary" content like programatically-generated workshop details, a join button, and a code of conduct link.
https://github.com/WordPress/learn/blob/beacb50998a874fc5f90dd134074c8a59f9b313c/wp-content/plugins/wporg-learn/inc/post-type.php#L208-L236
Problems
Because of the way it's setup, changes won't apply to existing posts automatically, like they would with a traditional theme's
single-workshop.php
template. We'd have to manually update old posts to use the new template. There have already been some changes to the template, so many posts are using different templates. See WordPress/gutenberg#7961It also hardcodes the "secondary" content into
post_content
, when it should be applied dynamically. That content isn't supposed to change between posts (other than i18n, which can be handled dynamically). Right now there are non-English posts that have the button in English, because it wasn't translated inpost_content
.The block template also allows the sidebar content to be removed, because
template_lock
isn't inherited to Column blocks. See WordPress/gutenberg#8112 and WordPress/gutenberg#9386.Potential Solutions
We started discussing the issue in https://wordpress.slack.com/archives/C01KC5VDQBC/p1614641586017200 and
https://wordpress.slack.com/archives/C01KC5VDQBC/p1614645458026200.
It looks like WordPress/gutenberg#26128 helps solve some of the locking issue, by letting us control modifications to a column.
There doesn't seem to be a straightforward solution for storing the "secondary" content outside of
post_content
, though. I looked into how FSE might help that, but it doesn't seem like the beta is far enough along to be useful in production. I'm guessing we'd likely run into problems implementing exactly what we want, and would have to change stuff once the MVP is done. I'd be happy to be corrected about that, though, if anyone sees a way I missed.If not, I can see two ideas:
Just update the current block template w/ the new fields, similar to how past changes were done. Then, either: A) ignore old posts; or B) manually update old posts.
Create a "workshop" block, and make that be the only thing in the template. This may not the "correct" way in a post-FSE world, but it might be a decent compromise today.
render
function could useInnerBlocks
to define the template. But the block would have distinctEdit
andSave
components.Edit
would display the "secondary" blocks -- so that the user has a WYSIWYG experience -- butSave
would only save the "primary" content intopost_content
. The secondary content would get saved to post meta. For the WPTV embed,Save
could pick the URL from theEmbed
block and save it to a post meta field, so that we wouldn't have to modify theEmbed
block itself.wp-content/themes/wporg-learn/single-workshop.php
) would render the "secondary" content dynamically.Does anyone have any thoughts?
@ryelle , @noisysocks , @StevenDufresne , @coreymckrill
The text was updated successfully, but these errors were encountered: