Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted March 19, 20205 yr I'm looking for add some custom HTML with some translations. Does anyone hide and show blocks according to language?
March 23, 20205 yr 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 March 30, 20204 yr by Morrigan
March 23, 20205 yr 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.
March 30, 20204 yr Author 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.
March 30, 20204 yr You don't want it in PHP, this is code for a standard HTML block. I realized that the if statement (the first bit) is missing brackets it should be double brackets so {{ and }} I fixed my original code. Edited March 30, 20204 yr by Morrigan