Jump to content

wire404() doesn't work, localhost redirected you too many times.


Recommended Posts

I have different pages, some of which have german and others have english content. The default language of the website is english.

I want to show only german content when on the german site (/de/) and english when on the english site (/en/). I could deactivate a german page in the page's settings when needed but I can't just deactivate the english version in some cases cause it's the default language, so that's not the right way.

I put a selector-field on the page's template with which the page's language is selected and managed to have at least the overview of pages (one level above) to only display what matches the currently viewed language. 

But what about the page-view itself? I thought I put an if-condition on the page's template itself and if the page's language matches the currently viewed language, it either displays the content or "throws" a 404error.

Is that a good way to go about this issue?

Anyway, it doesn't work as expected, I get

This page isn’t working
localhost redirected you too many times.

Here's my code…

if ($page->linguafranca->title != _x('en', 'HTML language code')) :
else : 
// content goes here

Thanks for help!

Link to comment
Share on other sites

1 hour ago, fruid said:

if ($page->linguafranca->title != _x('en', 'HTML language code')) :

I'm not sure I understand completely, but the above line looks strange to me. In plain english, what are you asking PW here? And why the _() and not just a plain string?

Maybe you should query the current user's language first, and then go from there

$currLangName = $user->language->name; // "en" -> will be "default" if it's the default language
$currLangTitle = $user->language->title; // "English"


Link to comment
Share on other sites

Maybe my question should be much more general.

When I say "pages" I should probably say "posts" because technically that's what they are. They are sorted by date, listed on the parent page and when you open them you see them in detail. I have 2 languages, english as default and german, and the posts can be in english OR in german but (probably) never both, so they should only be listed on the appropriate language version. 

How can I accomplish that since, like I mentioned, I can't "turn off" the default language for the posts individually (change the status to not-active in its settings), only german?

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

  • Recently Browsing   0 members

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