Jump to content

Hide and show blocks according to language


Recommended Posts

You would have to do it at the block/page level because currently there is no way to do it otherwise. You would add something like this around the block @Jorge Varela

{{if \IPS\Member::loggedIn()->language()->bcp47() == 'en-US'}}
Block stuff here for English
{{endif}}

Replacing en-US with the language for the respective block.

Edited by Morrigan
Link to comment
Share on other sites

3 hours ago, Morrigan said:

You would have to do it at the block/page level because currently there is no way to do it otherwise. You would add something like this around the block @Jorge Varela


{if \IPS\Member::loggedIn()->language()->bcp47() == 'en-US'}
Block stuff here for English
{{endif}}

Replacing en-US with the language for the respective block.

Yes, that works. It's also a fair bit to type, so in my site I have it in a shorter form:

{{if member.language()->id === 1 }}
	English
{{else}}
	Esperanto
{{endif}}

en_US in my site has the id 1. You'll have to adjust your code as necessary.

Link to comment
Share on other sites

On 3/23/2020 at 2:03 AM, Morrigan said:

You would have to do it at the block/page level because currently there is no way to do it otherwise. You would add something like this around the block @Jorge Varela


{if \IPS\Member::loggedIn()->language()->bcp47() == 'en-US'}
Block stuff here for English
{{endif}}

Replacing en-US with the language for the respective block.

Thanks for your help. I tried to add this but im not sure how to do it. Could you please explain me how to tackle it?  I'm creating a PHP module and creating the if statement  but It's throwing me an error. What should I add? I'm just adding the if statement. 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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