Currently Neos renders 404 and 410 status results by default as error messages and relies on external packages to enable things like editable 404 pages.
At the sprint in salzburg we agreed that this should be a feature the core itself offers but we had no favorite way of implementing this yet.
I suggest to implement native error rendering via fusion with the following steps.
Use the fusion path “error” in addition to “root” as second main entry point to fusion in case of an error occurred.
When the “error” path is evaluated the context contains “error”, “site” and “request” since we obviously were not able to determine a matching documentNode.
To actually trigger the fusion rendering special fusion based rendering for the ErrorHandler is defined.
# the error matcher
error = Neos.Fusion:Case {
# this is a custom matcher will be rendered if a 404 status
# is rendered by fusion, it will detect a document and by
# project specific criteria and render it using the "/root" fusion path
404 {
condition = ${error.status == 404}
@context.documentNode = ${q(site).children('[uriPathSegment == 404]').get()}
@context.node = ${q(site).children('[uriPathSegment == 404]').get()}
renderPath = '/root'
}
# this is the default matcher that would be come with the core
# and renders exactly the same message as today
default {
condition = true
renderer = Neos.Fusion:ErrorMessage {
title = ${error.message}
}
}
}
Hey @mficzel,
that’s a really slick solution, I like!
Please extend the RFC to a RFC: 4xx Error rendering in Neos, as handling 403 for example is also important.
Would it make sense, to provide some prototype for that 4xx {} block?
Like this approach, it’s simple and straight forward. When we’ve discussed this in the past there weren’t really one standard approach to page rendering and such, so creating a solution that fit all was not really doable. However as Neos rendering has changed and matured, that’s now better possible.
BTW: I will probably not be able to implement this anytime soon as my next topics will be the agency-list and the 4.3 release. I mainly wanted to document the idea and not sit on it. If anyone has an itch to implement it now i am totally fine with it.