Jump to content

Why would the pages of a template be invisible in the non-default language?


da²
 Share

Recommended Posts

Hello,

My site (PW 3.0.240), using multi-language URLs since a few months, has default language french, and another language english.

I don't know why, but a specific template is not accessible to english on front-end:

  • If I go to the english URL of one of these pages, I get a 404.
  • If I go to one of this pages in french, the language switcher shows only french as available language.
  • If I display the pages of this template while using english, I get an empty list.

I found that I checked in "template > advanced" the option "Disable multi-language support for this template" but:

  • Enabling it again doesn't solve the issue.
  • This option doesn't show a 404, it just switch language to default when loading this page. That was a mistake to check it, but not the cause of this issue (apparently).

 

While writing this post, I investigated more and found the following.

 

I finally found what makes these pages unreachable in english, this in the pages themselves, this checkbox is disabled in Settings tab:

image.thumb.png.deb87c6f665a9889ea52dd15ba1501a3.png

These pages are created dynamically, why is this "active" checkbox disabled, is it expected, and how to enable it automatically?

This is more serious than it looks, because it ends with important bugs in the site and database inconsistencies.
The problematic template represents a team in a competition. When a user using english language registers to a championship and creates a team, it is well created, BUT when he leaves the championship the team is not deleted because the find() method is not returning it, and the user is still referenced in the team even if not in this championship anymore.
I'm disabling english to avoid more damages until I can fix this properly.

How can I fix this? And if you have informations about this behavior, please explain or give documentation links, I'm a bit lost actually.

Edited by da²
Link to comment
Share on other sites

  On 1/30/2025 at 4:48 PM, da² said:

These pages are created dynamically, why is this "active" checkbox disabled, is it expected, and how to enable it automatically?

Expand  

I guess it's expected because it's been observed since 2013 at least. Discussion and code snippets in this topic: 

 

  • Like 2
Link to comment
Share on other sites

Thanks, I find this behavior a bit odd and think the option implemented in RockMigrations could be on the core module "Page Names".

Creating pages via API doesn't use the same behavior as when using the admin interface, or even when generating pages within an admin hook (all languages are activated by default in these cases). I don't understand why this is different in a hook and when bootstrapping PW.
Also, when we add a new language, every existing page is automatically enabled for this language, so why not doing it by default when a new page is created on front-end?
Do you know the reasons behind these choices?

Edited by da²
Link to comment
Share on other sites

  • da² changed the title to Why would the pages of a template be invisible in the non-default language?

What is disturbing me the most is the fact that I'm not finding pages (using Pages API) that are not enabled for the current user language.
For example, I have a few templates that are not meant to be translated, so I disabled multi-language management ("Settings tab" in the template). But if user is not using the default language I don't find them.

pages()->find('template=foo'); // Need all pages even if not enabled for current user language

In Page Names module option, we can avoid the page to show a 404 and make it render in default language, but it's missing the same option using API to find pages (find(), children()...).

I see 2 workarounds, not really satisfying:

  • Always enable all languages on every page and template, even if they are not meant to be translated.
  • Set user language to default before every kind of page search. This is too much, and error prone.

A global option would be better.

Maybe I'm missing another option?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...