Grab content for the 404 page in all languages

Created on 15 February 2024, 9 months ago
Updated 30 May 2024, 6 months ago

Problem/Motivation

  • Now that we've learned a bit more about how this module works we're thinking that it needs one more option, this option would load the 404 node body field value instead of the themed_fast_404 settings text. It would be an added option to the themed_fast_404 configuration form and logic added to make this work

I installed the module in a Drupal site with 2 languages, french (main language) and english (second language).

The 404 page in english works OK but in french it doesnt grab the content of the 404 page, it takes the text of the configuration page.

Proposed resolution

The module should take the content of the 404 page for all the languages.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada jcninov

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jcninov
  • 🇷🇸Serbia g_miric

    @jcninov If you run cron again it should take the value from configuration page for english language too.

    It is designed to override/ignore the default 404 page and use the value from configuration page.
    If you have an issue with translating 404 page body value this issue 📌 Support config translation Fixed fixes it.

  • 🇨🇦Canada joseph.olstad

    @g_miric, I work with @jcninov and observed the issue with him. What we're actually looking for is the default 404 page text rather than the value from the configuration page.

    I'm working on a patch that will provide an option to choose which 404 page to use.

  • 🇨🇦Canada joseph.olstad

    Example, our french page is the source version of our 404 page has some nice content.

    "Page introuvable"

    Screenshot:

    and the translated page also has some nice content.

    Screenshot:

    We would like to see the above in our themed_fast_404 page instead of the configuration text.

  • 🇨🇦Canada joseph.olstad

    This is what we are seeing with the Themed fast 404 configuration text enabled.

    Screenshot:

    Do you see why we would just want our original 404 page values?

  • 🇨🇦Canada joseph.olstad

    I'm hitting some roadblocks getting my environment going, unable to write the patch today.

  • 🇨🇦Canada joseph.olstad

    So what I've found so far is that the 1.0.5 version still seems to have the same behavior as the 1.0.4 version.

    With that said, what I would like to see is the Default 404 (not found) page body content be optionally loaded in place of the themed_fast_404 settings text value.

    For example, go to the /admin/config/system/site-information page, here we find our 404 node value which is /node/123 , what would seem to make sense would be to load the node 123, grab the body field value and use that optionally instead of the themed_fast_404 settings text value.

    Assuming this logic would go into the src/Controller/ThemedFast404Controller.php.

    With that said, for some reason the sites/default/files/page-not-found-fr.html content that is generated is still using the settings value but the sites/default/files/page-not-found-en.html gets the expected node values even though I haven't changed any code from 1.0.5 .

    The translation UI seems broken also.

  • 🇨🇦Canada joseph.olstad

    or if we could just get the non-fettered 404 page like what we currently see from the en.html file.

    we're getting exactly what we want from our screenshot for en.

  • 🇷🇸Serbia g_miric

    Hi @joseph.olstad

    Originally it was designed to override the default 404 page too, but this could be a feature request:

    • There could be a checkbox (e.g. "Use content from 404 config page instead") in the config page below or above the 404 body field
    • themed_fast_404 should get content of that page (it doesn't need to be node path)

    I will work on that as soon as I'm available.

    With that said, for some reason the sites/default/files/page-not-found-fr.html content that is generated is still using the settings value but the sites/default/files/page-not-found-en.html gets the expected node values even though I haven't changed any code from 1.0.5 .

    The translation UI seems broken also.

    I'm not able to reproduce any of these issues. Installed a new Drupal 10 site, added EN and FR languages, set FR as the default language, translated 404 config page, run cron, tested on EN and FR path and it looks good.

  • Assigned to joseph.olstad
  • 🇨🇦Canada joseph.olstad

    Here's the idea of the start of a patch that we're looking at .

    Everyones theme is different so we'd have to also add a openning html and closing html configuration to allow this to be configurable.

    For this patch I've hard coded some of our template that was missing from the 404.

    With this, our 404 page renders as expected in both languages.

    There's probably some hidden mysteries in our build but with that said, I think it's a sort of a frequent use case to want to use the 404 page body content as we're proposing to do here.

  • 🇨🇦Canada joseph.olstad

    There's other stuff going on that I can't yet explain, but perhaps this start of a patch will lead to something

  • 🇨🇦Canada joseph.olstad

    oops patch #13 was unlucky.

    New patch

  • 🇷🇸Serbia g_miric

    Hi @joseph.olstad,

    If this patch works for you, you could apply it at the moment, but globally this wouldn't work:
    - It overrides the fast 404 message and that should be optional.
    - It assumes that 404 config path starts with "node/" if it's a node, but it could be an alias too.
    - It renders only the body field, and it should render the whole page (there could be no body field at all).
    - It should support any type of url, e.g. it could be custom route

    I will work on this feature as soon as I get some time.

  • 🇨🇦Canada joseph.olstad

    @g_miric, yes, this could all become configurable, and yes good points made accross the board to make this work for everyone additional work is needed on the patch , with that said, it is the 404 body field that was desired in our case.

  • Status changed to Closed: duplicate 6 months ago
  • 🇷🇸Serbia g_miric

    The new feature will be implemented within #3450805 Make the 404 page more configurable Needs work so I'm closing this issue.

  • Status changed to Active 6 months ago
  • 🇨🇦Canada joseph.olstad

    I looked over the other issue:
    Make the 404 page more configurable Needs work

    It is not a duplicate from what I can see. Doesn't get the configured 404 page node body field value for all active languages.

  • 🇨🇦Canada joseph.olstad

    The designated 404 page can be any route, but can be a node, in many cases it would be expected to have complex content such as an image with a person shrugging their shoulders and looking up.
    Nodes can be 404 pages

    this is what our patch above deals with.

    the designated 404 page is configured here: /admin/config/system/site-information

    if it's a node, we should use the body field data , and load the expected translation value also.

  • 🇷🇸Serbia g_miric

    @joseph.olstad That is exactly what the new patch is doing. If there is a 404 page set in the "system.site" config and "use_system_404" is set to TRUE, it will take the get the page and make it static.

    It doesn't make sense to take only the body field. In fact, the node that is set as the 404 page doesn't need to have a body field.

    And if you really need to render only the body field then you should adjust the template for that node or to use the module setting "404 page body"

Production build 0.71.5 2024