skmd Posted November 18, 2007 Share Posted November 18, 2007 hi everybody im trying to add this code to my header.tpl but it doesnt work can anybody help me. i wan to display pict1.jpg if the language were spanish and else i want to display pict2.jpg <?PHP if (setlanguage=true&language=spanish) { echo '[img=../../../images/pict1.jpg]'; } else { echo '[img=../../../images/pict2.jpg]'; }?> 0 Quote Link to comment Share on other sites More sharing options...
masgra Posted November 18, 2007 Share Posted November 18, 2007 skmd, WHMCS uses SMARTY templates, so you have to replace the php opening tag (<?php) with {php}, and the php closing tag (?>) with {/php}. 0 Quote Link to comment Share on other sites More sharing options...
skmd Posted November 18, 2007 Author Share Posted November 18, 2007 I tried this but it didnt work too I have tried to remove the opening tags didnt work too 0 Quote Link to comment Share on other sites More sharing options...
masgra Posted November 18, 2007 Share Posted November 18, 2007 Just to confirm, the following did NOT work: {php} if (setlanguage=true&language=spanish) { echo '[img=../../../images/pict1.jpg]'; } else { echo '[img=../../../images/pict2.jpg]'; } {/php} 0 Quote Link to comment Share on other sites More sharing options...
bear Posted November 18, 2007 Share Posted November 18, 2007 You didn't end the "if" statement, and it's not formatted correctly if you want it to be through Smarty. Should be: {if setlanguage=true&language=spanish} {else} {/if} 0 Quote Link to comment Share on other sites More sharing options...
skmd Posted November 18, 2007 Author Share Posted November 18, 2007 it didint work too, can anybody check if this is a valid for "if" setlanguage=true&language=spanish 0 Quote Link to comment Share on other sites More sharing options...
bear Posted November 18, 2007 Share Posted November 18, 2007 Have you tried this to troubleshoot it? The basic template syntax can be seen by looking at the templates. All pages have specific variables which you can use. To view a complete list of variables available on a page, enter the following command into the template file: {debug} 0 Quote Link to comment Share on other sites More sharing options...
skmd Posted November 18, 2007 Author Share Posted November 18, 2007 ok, i made this one , the page is displaying now but every time it shows me pict2.jpg {if $setlanguage==true && $lang==spanish} {else} {/if} does anybody knows why? 0 Quote Link to comment Share on other sites More sharing options...
bear Posted November 18, 2007 Share Posted November 18, 2007 That would have to mean it thinks "else" is true, or in other words, it's not seeing your language variable from the "if". 0 Quote Link to comment Share on other sites More sharing options...
skmd Posted November 18, 2007 Author Share Posted November 18, 2007 ok, I expect that. what i suppose to do?what is the veriable you are using for languages? 0 Quote Link to comment Share on other sites More sharing options...
bear Posted November 18, 2007 Share Posted November 18, 2007 I don't offer other languages, but you may be using the wrong variable here. In a link to switch languages, it's this: "order.php?setlanguage=true&language=Spanish". I'd suggest trying your code like this: "{if $language eq Spanish}". I believe "$LANG" refers to the language file that's set to be used, as in "$LANG.variablename", which would replace the variable with that phrase from the chosen language file. 0 Quote Link to comment Share on other sites More sharing options...
skmd Posted November 18, 2007 Author Share Posted November 18, 2007 Unfortionatly, It didnt work too.any other help ?? 0 Quote Link to comment Share on other sites More sharing options...
masgra Posted November 18, 2007 Share Posted November 18, 2007 skmd, I put a {debug} in my code and there is no reference to the currently selected language available. You will probably need to raise a ticket to see if Matt can add a SMARTY variable for the current language before what you are trying to do will be possible. 0 Quote Link to comment Share on other sites More sharing options...
masgra Posted November 18, 2007 Share Posted November 18, 2007 skmd, Here is a solution for you using a known variable value from the language files - $hometitle: {if $hometitle=='Inicio'} [img=../../../images/your_spanish.jpg] {else} [img=../../../images/your_english.jpg] {/if} $hometitle is avaiable throughout the client area, so should work for what you are trying to do. 0 Quote Link to comment Share on other sites More sharing options...
skmd Posted November 18, 2007 Author Share Posted November 18, 2007 r u sure its working ? because it didnt work for me ? 0 Quote Link to comment Share on other sites More sharing options...
masgra Posted November 18, 2007 Share Posted November 18, 2007 Try it without the trailing / in the img tag: {if $hometitle=='Inicio'} [img=../../../images/your_spanish.jpg] {else} [img=../../../images/your_english.jpg] {/if} Also replace 'Inicio' with what ever you have in your Spanish language file for $hometitle. 0 Quote Link to comment Share on other sites More sharing options...
skmd Posted November 19, 2007 Author Share Posted November 19, 2007 its not working, it shows as a text " " not an image and even the if function is not working every time shows the "else" function 0 Quote Link to comment Share on other sites More sharing options...
robbo Posted November 19, 2007 Share Posted November 19, 2007 This might help: {if $LANG.language == "Idioma"} <img src="../../../images/your_spanish.jpg"> {else} <img src="../../../images/your_english.jpg"> {/if} If you have changed the $_LANG["language"] = "Idioma"; in your language file, change the "Idioma" in the if statement to correspond with the correct word. 0 Quote Link to comment Share on other sites More sharing options...
skmd Posted November 20, 2007 Author Share Posted November 20, 2007 hey man it worked,it worked finally thank u so much u rock 0 Quote Link to comment Share on other sites More sharing options...
alain100 Posted September 29, 2009 Share Posted September 29, 2009 Hey, I don't know if you still need it. {if $language eq 'English'} Hello {else} Bonjour {/if} You can use it on any pages on your site 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.