Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Jorge Varela Posted March 19, 2020 Posted March 19, 2020 I'm looking for add some custom HTML with some translations. Does anyone hide and show blocks according to language?
Morrigan Posted March 23, 2020 Posted March 23, 2020 (edited) 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, 2020 by Morrigan Meddysong and Jorge Varela 2
Meddysong Posted March 23, 2020 Posted March 23, 2020 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. Jorge Varela and WP V0RT3X 2
Jorge Varela Posted March 30, 2020 Author Posted March 30, 2020 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.
Morrigan Posted March 30, 2020 Posted March 30, 2020 (edited) 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, 2020 by Morrigan
Recommended Posts