tractorcow-farm / silverstripe-fluent

Multi-language translate module for Silverstripe, without having to manage separate site trees.
BSD 3-Clause "New" or "Revised" License
93 stars 111 forks source link

Error page type with 404 code can’t preview in CMS #904

Open pack254 opened 3 weeks ago

pack254 commented 3 weeks ago

Module version(s) affected

7.1

Description

I have a SilverStripe\ErrorPage\ErrorPage page type in the project which sets the ErrorCode to 404. When I am in the CMS, to split view to preview the page. it shows the/admin/pages page instead. I have found this caused by LocaleSwitchRedirector.

How to reproduce

  1. Create any two locales
  2. Edit ErrorPage type with 404 code
  3. Preview the page by split view, you will see it display the admin/pages instead of error page template.

Possible Solution

I have temporarily fixed it by using the Injector and added the additional condition for it, !$request->getVar('CMSPreview').

Additional Context

Screenshot 2024-10-31 at 4 37 52 PM

Validations

tractorcow commented 3 weeks ago

I think that temporary fix is fine as a permanent fix. Do you want to PR the change to add the extra condition?

pack254 commented 3 weeks ago

Yep, sure thing! I will raise a PR for this @tractorcow 👍