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

CMSPreview should be considered "frontend" #775

Closed
chrispenny opened this issue Jan 23, 2023 · 7 comments
Closed

CMSPreview should be considered "frontend" #775

chrispenny opened this issue Jan 23, 2023 · 7 comments

Comments

@chrispenny
Copy link

A common complaint that we're receiving from authors is that when they use the CMS Preview window, they are seeing things that they don't expect, EG: content that is not localised, or content that should have been filtered out with their assignment of "Filtered Locales". If the author browses to the frontend with ?stage=Stage, then they will receive the expected behaviour.

Currently, CMSPreview is treated as "backend" (isFrontend = false). This means that localisation and Filtered Locale logic is applied as if you were browsing the CMS. Which, I get that we are "in the CMS", but the practical purpose of the Preview window is to present the frontend experience that users will receive once the page is published.

InitStateMiddleware::getIsFrontend() currently contains a specific condition to treat CMSPreview as "backend".

// If using the CMS preview, do not treat the site as frontend
if ($request->getVar('CMSPreview')) {
    return false;
}

I would like to propose removing this condition, so that the Preview window provides the same experience as browsing to the frontend with ?stage=Stage.

@tractorcow
Copy link
Collaborator

Yes I think you are right. preview should be "as frontend", so admin filters don't make sense.

The only point of having an admin filter is so that you could see potential items (unfiltered) in order to make them available on the frontend.

@chrispenny
Copy link
Author

I was able to find the reason why we (probably) made CMS preview be treated as "backend".

If you are browsing the CMS in Split or Preview mode, and you click on a page that is not localised, the Preview window redirects you to the 404 page - both in the Preview window (which would be expected), but also in the CMS edit form (which is unexpected).

export.mov

I'm not entirely sure what the path forward would be. I do think that the expected behaviour for the Preview window would be to receive the 404 page, but it's not ideal that the CMS edit form also loads the 404 page.

@tractorcow
Copy link
Collaborator

We could have a message to localise the page in draft before you can preview it?

@chrispenny
Copy link
Author

It's maybe just a bit tricky because the localisation interface is in that page (which you can't get to). Yea they could switch to a locale that has content, but which localised have a localisation might not even be immediately obvious to authors.

I don't suppose there's an easy way to force the CMS edit form to load with preview closed? Like a GET param or something that we could attach to the edit link if we see the page is unlocalised?

@tractorcow
Copy link
Collaborator

middleware for 404 that detects draft querystring, and renders the message ?

@GuySartorelli
Copy link
Contributor

GuySartorelli commented Feb 16, 2023

I don't suppose there's an easy way to force the CMS edit form to load with preview closed? Like a GET param or something that we could attach to the edit link if we see the page is unlocalised?

You could implement updatePreviewLink() in the site tree fluent extension and set the preview link to null if the page isn't localised. That will have the preview panel collapsed (edit mode) by default when viewing that page's edit form, and if you manually swap to preview or split mode it'll just say "no preview available" (or whatever that message is).

@GuySartorelli
Copy link
Contributor

I created a PR to address this: #781

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants