Jikdor Posted January 16, 2011 Share Posted January 16, 2011 Hello Presta forums!I have 2 domains for my website, one .se for Swedish and a .com domain for English and I would like them to control what language that is used and not load it from a cookie and the flag icons will just point to the different domains. This should be a simple edit but I can not find where is the code the language ID is defined. I was thinking something like: if ($_SERVER['SERVER_NAME'] == "psybackdrops.com") { $id_lang = "1"; } elseif ($_SERVER['SERVER_NAME'] == "www.psybackdrops.com") { $id_lang = "1"; } elseif ($_SERVER['SERVER_NAME'] == "psybackdrops.se") { $id_lang = "4"; } elseif ($_SERVER['SERVER_NAME'] == "www.psybackdrops.se") { $id_lang = "4"; } So where in the source code does presta find out what language id to use and how do I edit it to work as I want? I'm thinking it is in smarty.config.inc.php but being a php noob and not slept in days I failed to figure it out and make it work. Help would be very appreciated!! Link to comment Share on other sites More sharing options...
rocky Posted January 16, 2011 Share Posted January 16, 2011 You must change it in the cookie. For example: if ($_SERVER['SERVER_NAME'] == "psybackdrops.com" OR $_SERVER['SERVER_NAME'] == "www.psybackdrops.com") $cookie->id_lang = 1; elseif ($_SERVER['SERVER_NAME'] == "psybackdrops.se" OR $_SERVER['SERVER_NAME'] == "www.psybackdrops.se") $cookie->id_lang = 4; Link to comment Share on other sites More sharing options...
Jikdor Posted January 27, 2011 Author Share Posted January 27, 2011 Thank you for the help! Link to comment Share on other sites More sharing options...
rocky Posted January 27, 2011 Share Posted January 27, 2011 If your issue is resolved, please edit your first post and add [sOLVED] to the front of the title. Link to comment Share on other sites More sharing options...
Jikdor Posted January 27, 2011 Author Share Posted January 27, 2011 Hmm I have not solved this yet, the code seems to have no effect. Where exactly do I put it? Link to comment Share on other sites More sharing options...
Jikdor Posted January 27, 2011 Author Share Posted January 27, 2011 It nows does change the language, but does the oposit of what I want. Used English for the se domain and Swedish for the com. Weird. I don't understand at all why its acting this way, makes no sense!NVM got it workingEdit:Nope it's not working as I want after all, it sometimes workes, sometimes it don't! Link to comment Share on other sites More sharing options...
rocky Posted January 27, 2011 Share Posted January 27, 2011 Put it in init.php, after line 22: $cookie = new Cookie('ps'); Link to comment Share on other sites More sharing options...
Jikdor Posted January 27, 2011 Author Share Posted January 27, 2011 Thank you rocky a cookie to you! Link to comment Share on other sites More sharing options...
adamus007p Posted March 19, 2011 Share Posted March 19, 2011 hello and what about robots and htaccess modification any change? Link to comment Share on other sites More sharing options...
adamus007p Posted May 3, 2011 Share Posted May 3, 2011 Is this work with P. 1.4.1? Link to comment Share on other sites More sharing options...
skurek Posted January 12, 2012 Share Posted January 12, 2012 yes, but you must change file FrontContoller.php from classes after line 116. Tools::switchLanguage(); code: if ($_SERVER['SERVER_NAME'] == "psybackdrops.com" OR $_SERVER['SERVER_NAME'] == "www.psybackdrops.com") $cookie->id_lang = 1; elseif ($_SERVER['SERVER_NAME'] == "psybackdrops.se" OR $_SERVER['SERVER_NAME'] == "www.psybackdrops.se") $cookie->id_lang = 4; Link to comment Share on other sites More sharing options...
MarcusAT Posted January 12, 2012 Share Posted January 12, 2012 yes, but you must change file FrontContoller.php from classes after line 116. Tools::switchLanguage(); code: if ($_SERVER['SERVER_NAME'] == "psybackdrops.com" OR $_SERVER['SERVER_NAME'] == "www.psybackdrops.com") $cookie->id_lang = 1; elseif ($_SERVER['SERVER_NAME'] == "psybackdrops.se" OR $_SERVER['SERVER_NAME'] == "www.psybackdrops.se") $cookie->id_lang = 4; Thanks for this Skurek! Should this code replace the following code?: if (!defined('_USER_ID_LANG_')) define('_USER_ID_LANG_', (int)$cookie->id_lang); And also, how would I set up the second domain on the registrar site? If one is the prestashop domain, how do I configure the other one? Link to comment Share on other sites More sharing options...
shopimport.nl Posted February 20, 2013 Share Posted February 20, 2013 I like to switch language initially based on the .TLD of the domain (so .fr .de .co.uk etc) for PS 1.5. I did this in PS 1.3 in the init.php. I think it should now be in frontController like proposed but 1.5 doesn't have switchLanguage() It does have Tools::setCookieLanguage($this->context->cookie); and I tried to switch in the override for Tools class. The code was functioning BUT something before this code is already setting the cookie. And a only want to set the language when no language is selected yet. 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