Jorge Varela Posted March 19, 2020 Share Posted March 19, 2020 I'm looking for add some custom HTML with some translations. Does anyone hide and show blocks according to language? Link to comment Share on other sites More sharing options...
Morrigan Posted March 23, 2020 Share 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 Jorge Varela and Meddysong 2 Link to comment Share on other sites More sharing options...
Meddysong Posted March 23, 2020 Share 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. WP V0RT3X and Jorge Varela 2 Link to comment Share on other sites More sharing options...
Jorge Varela Posted March 30, 2020 Author Share 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. Link to comment Share on other sites More sharing options...
Morrigan Posted March 30, 2020 Share 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 Link to comment Share on other sites More sharing options...
Recommended Posts