Jump to content

Community

Different content on page


Thomas Hop
 Share

Go to solution Solved by bfarber,

Recommended Posts

Hey guys,

I have several pages that I made in the Pages application where I have some general information etc. But it's only viewable in the standard Dutch language of the website. I have English translations for every page but how can I make it so that whenever a user is using the English language the page is showing an English text. 

The only thing I can change is the name of the page based on language. But I need to change the content.

Anyone knows how to do this?

 

Kind regards

Link to comment
Share on other sites

It is possible with code in a manual HTML page actually. Much less so with a page builder page. Check against \IPS\Member::loggedIn()->language()->id or if preferring to check against locale strings instead of numbers, \IPS\Member::loggedIn()->language()->short

Despite the apparent use of a logged in member object, this works for guests as well due to the way \IPS\Member works.

Alternatively, see this post. In 3.x any admin could just add a language string, but that was removed from the core in 4.x, or I would have just said to dump them into the language system to begin with.

Edited by Marcher Technologies
Link to comment
Share on other sites

  • Solution

If you are creating a page in Pages, you can do this using HTML logic based on Marcher's suggestion.

If you are adding a database record, however, it is not possible. Translatable fields should ONLY be available to administrators, however quite often database records can and are added on the front end, so we enter a bit of a gray zone there. I've seen this question come up before, but it's not as straightforward as it may seem from a software POV when you only consider one usage.

The custom language strings approach is honestly your best option, even if it requires a separate app.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We use technologies, such as cookies, to customise content and advertising, to provide social media features and to analyse traffic to the site. We also share information about your use of our site with our trusted social media, advertising and analytics partners. See more about cookies and our Privacy Policy