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

No redirect when switching language between 2 translation of boxes page #187

Open
Zmove opened this issue Jan 11, 2025 · 6 comments
Open
Labels
bug Something isn't working

Comments

@Zmove
Copy link

Zmove commented Jan 11, 2025

Describe the bug
I have a website in 2 language, french and english. I created a box page for the french website, and the translation for the english website.

My french page have /page-fr url, the english page have /page-en url.

If I browse my website in french, go to my french page, no problem.
But if I switch the website language whereas I'm on the french page, I'm redirected to the 404 page because I'm on the english website, domain changed, but the page url page-fr and not page-en. The url has not been converted to use the english url

Boxes Version
3.6.43

To Reproduce

  • Create 2 websites using october multisite feature
  • Create a box for site 1
  • Copy the box to site 2 and change it's url
  • Go to your box page on site 1
  • Use sitePicker component to switch language
  • You will be redirected to a 404 page instead of being redirect to the equivalent box page on site 2

Best regards,

@Zmove Zmove added the bug Something isn't working label Jan 11, 2025
@Zmove
Copy link
Author

Zmove commented Jan 11, 2025

I noticed an option that seems to handle that case, but I have all my pages for all my websites, and that dropdown that allow to select what is the equivalent page for the others sites is always empty. I think the problem is here :

image

@tobias-kuendig
Copy link
Member

That dropdown gets populated by plugins/offline/boxes/classes/traits/HasMultisiteSupport.php in the getSiteRootIdOptions method.

Could you check what that query returns on your setup? You should get a list of all pages that belong to the site that is marked as primary.

In that dropdown you can select what pages belong together so redirects between sites work correctly.

@Zmove
Copy link
Author

Zmove commented Jan 13, 2025

I traced the following query :

trace_log(Page::withoutGlobalScope(MultisiteScope::class)
        ->with('site')
        ->currentDrafts($useSite)
        ->get()
        ->pipe(fn ($pages) => new PatchedTreeCollection($pages))
        ->listsNested('name', 'id'));

It return an empty array whereas I have several pages on the different sites, do I have to check another setting in the backend in order to make pages appears in that list ?

@tobias-kuendig
Copy link
Member

Thank you for testing this, @Zmove! Could you check which clause on the query makes it return no results?

Either

Page::withoutGlobalScope(MultisiteScope::class)->get()

or

Page::currentDrafts($useSite)->get()

should return something.

So it is either the currentDrafts scope oder the MultisiteScope that prevents the data from being returned.

@Zmove
Copy link
Author

Zmove commented Jan 14, 2025

trace_log(Page::withoutGlobalScope(MultisiteScope::class)->get());

return results

trace_log(Page::currentDrafts($useSite)->get());

return empty array

@tobias-kuendig
Copy link
Member

@Zmove can you check your system_site_definitions table and see what site has the is_primary value set to 1?

According to your db dump, you mostly have pages on the sites 3-7. The dropdown selects the pages from your "primary site". So if for example a Site 1 exists, and it is set as primary, but has no pages attached, the dropdown will be empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants