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

Post Content: Add some text to the Post Content block when used in a 404 context #33570

Closed
wants to merge 2 commits into from

Conversation

scruffian
Copy link
Contributor

Description

Similarly to #33515, we should output some default copy on the page when the post content block is used in a 404 context. This makes the creation of 404 templates much simpler as themes can simply use the same template as their index.

How has this been tested?

  • Add a post content block to a 404 template
  • Confirm that you see the text "It looks like nothing was found at this location.".

Another benefit of this approach is that the default text can be translated. We might want to change the copy.

Screenshots

Screenshot 2021-07-20 at 14 40 05

Types of changes

New feature (non-breaking change which adds functionality)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@scruffian scruffian added the [Block] Post Content Affects the Post Content Block label Jul 20, 2021
@scruffian scruffian self-assigned this Jul 20, 2021
@scruffian scruffian requested a review from ajitbohra as a code owner July 20, 2021 13:41
@@ -17,6 +17,9 @@ function render_block_core_post_content( $attributes, $content, $block ) {
static $seen_ids = array();

if ( ! isset( $block->context['postId'] ) ) {
if ( is_404() ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 - I don't think we should be adding hardcoded content like that. Such content should be editable and removable. Even if we added a wrapper with a css class here, someone would have to use css to hide it.

In my head this is something to be handled in 404 template but it seems I can't understand how this is not working. For example right now that we have a 404 template in tt1-blocks with a custom header block - we can't make this translatable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have any way to translate content in the HTML files for block templates, or block template parts. I've made some other suggestions for how we might work around the problem:
#33192
#33217

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of the outcome of those PRs (I'm betting on #33217), this feels best absorbed by patterns than by hard-coded server-side logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if the patterns PR merges, I think this is a very useful tool. If I want to create a simple site with only one template, this allows me to do that...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I want to create a simple site with only one template

I think this is a good aspiration for FSE. Building simple sites should feel as convenient as working with a single template. But I think the current proposal is overloading base FSE blocks with meaning and hardcoded decisions.

@carolinan
Copy link
Contributor

carolinan commented Aug 3, 2021

I disagree with the approach because I think users should be able to change everything on the 404 template by editing the template.
Theme authors can still filter the content if it is a 404 page.

FSE themes don't have conditionals in the same way as classic PHP based themes do, if we want to implement that, then that needs to be a complete system, not a one off for the 404 page.

@scruffian scruffian closed this Aug 6, 2021
@scruffian scruffian deleted the update/post-content-404 branch August 6, 2021 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Content Affects the Post Content Block
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants