USB83 Posted September 12, 2016 Share Posted September 12, 2016 Hello, For a shop offered in two languages, I'm looking for a way to include a string of text in my template (default-bootstrap) but i only want that string to be displayed for visitors browsing the website in english. Here the html structure of the string i want to include : <div id="en-instructions">Lorem ipsum dolor sit amet, <a href=#">consectetur adipiscing elit</a></div> Can anyone help me with this ? Thanks a lot ! Link to comment Share on other sites More sharing options...
modprestashop Posted September 12, 2016 Share Posted September 12, 2016 That is simple, may be more simple than you thought. At very first, make it translatable string like this: <div id="en-instructions">{l s='Lorem ipsum dolor sit amet,'} <a href="#">{l s='consectetur adipiscing elit'}</a></div> Just go to your Translation panel in dashboard and replace your string with space in language for what you don't want to display it. Link to comment Share on other sites More sharing options...
USB83 Posted September 12, 2016 Author Share Posted September 12, 2016 Hello, Yes i thought about doing it that way (that's actually how i've been doing it so far) but i wanted to do it the right way, with an if statement in the template for example. Because now, even though in the browser view, the message is shown only when the website is set to english, i still have this in the source code with the other language : <div id="en-instructions"> <a href="http://random_url.com" target="_blank"> </a> </div> It's not a big deal but i'm learning php and theming so i'm looking for a solution to do it the right way and to learn at the same time Thanks a lot for your answer and your time anyway ! Link to comment Share on other sites More sharing options...
seofax Posted September 13, 2016 Share Posted September 13, 2016 That is simple, may be more simple than you thought. At very first, make it translatable string like this: <div id="en-instructions">{l s='Lorem ipsum dolor sit amet,'} <a href="#">{l s='consectetur adipiscing elit'}</a></div> Just go to your Translation panel in dashboard and replace your string with space in language for what you don't want to display it. i had the same problem but thanks to you i just solved it. Link to comment Share on other sites More sharing options...
Apium Posted September 13, 2016 Share Posted September 13, 2016 (edited) While the above solutions will work, translating something with an empty string feels like a 'hack', of sorts. It seems like a cleaner solution would be to not show the string altogether, via e.g. {if ($lang_iso == "en")}{l s='your string'}{/if} Not saying the other solutions are at all wrong, but this more closely reflects the actual behaviour you seemed to want. Edited September 13, 2016 by Apium (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now