nest Posted March 25, 2011 Share Posted March 25, 2011 Hi all,I need to change the background image defined in global.css for my store header depending on the language selected by the user.I'm thinking about if there is any way to define a conicional to change the image of header div on css depending the languaage selected.Thanks all for shared info! ; Link to comment Share on other sites More sharing options...
MrBaseball34 Posted March 25, 2011 Share Posted March 25, 2011 What is your site URL and PS version? Link to comment Share on other sites More sharing options...
nest Posted March 25, 2011 Author Share Posted March 25, 2011 Thanks for the interest.I've installed PS 1.4 (v1.4.0.17) but I don't have URL, I'm working on my future shop in localhost using Xampp.I think I need to edit: in the header.tpl to add a conditional to use different css classes depending the language selected but i don't know how to do... You think this is a good way to solve it? Link to comment Share on other sites More sharing options...
MrBaseball34 Posted March 25, 2011 Share Posted March 25, 2011 This has to be done in the FrontController where the CSS files are added to the $css_files variable. Search for "Tools::addCSS(_THEME_CSS_DIR_.'global.css', 'all');" in the /classes/FrontController.php unit.What you want to do is check the language and add the corresponding CSS file with the changes.I'm going through the same thing. I'm creating a site for NCAA apparel and need to change entire theme coloring based on the team (category) selected.Or, even easier, if you rename your global.css files according to the language you want to use, i.e. global_en.css and global_fr.css,then you can just change the code to this: Tools::addCSS(_THEME_CSS_DIR_.'global_'.Tools::getValue('isolang').'.css', 'all'); What image are you talking about that you want to change, anyway? Link to comment Share on other sites More sharing options...
nest Posted March 25, 2011 Author Share Posted March 25, 2011 Just working now, Simply and clever!Thanks a lot friend! Link to comment Share on other sites More sharing options...
nest Posted March 25, 2011 Author Share Posted March 25, 2011 Sorry, I've a little think to sove about this:When I write the URL directly in the browser the header don't charge the css styles and looks like into simple html without css but when I change the language doing a click into a flag then it load fine and if come back to default language by clicking the flag it shows fine this time. In resume, it fails in the first load but works fine when I change the language one time at least.Any idea to solve it? Thanks!! Link to comment Share on other sites More sharing options...
MrBaseball34 Posted March 25, 2011 Share Posted March 25, 2011 How are you passing the lang in the URL? Link to comment Share on other sites More sharing options...
nest Posted March 26, 2011 Author Share Posted March 26, 2011 First of all thanks for your time and interest, you're helping me a lot.When I enter the main url http://localhost/my-shop/ the home loads without the css styles but when I click on for example the spanish's flag the url changes to http://localhost/my-shop/es and home loads fine. If I click on english's flag the url changes to http://localhost/my-shop/en and works fine to. The problem begins when you enter from main URL without "/es" or "/en" directories.First I changed Tools::addCSS(_THEME_CSS_DIR_.'global_es.css', 'all'); to Tools::addCSS(_THEME_CSS_DIR_.'global_'.Tools::getValue('isolang').'.css', 'all'); and I get this error that I'm explaining.I tried to put both instructions like this: Tools::addCSS(_THEME_CSS_DIR_.'global_es.css', 'all'); Tools::addCSS(_THEME_CSS_DIR_.'global_'.Tools::getValue('isolang').'.css', 'all'); And now works fine and shows spanish language when you enter the main url http://localhost/my-shop/. Do you think that this is a good solution or can bring me problems in the future?Thanks a lot again!! Link to comment Share on other sites More sharing options...
MrBaseball34 Posted March 26, 2011 Share Posted March 26, 2011 Usually, your customers aren't going to enter your store that way. They will enter the base URL and click the flag of their language of choice.I understand the need to be "prepared for anything" but I am not that familiar with the way that PS handles languages because we use only English.I will do a little more digging and see if I can figure out hos to tell the lang from the URL. Link to comment Share on other sites More sharing options...
hhcj Posted April 12, 2011 Share Posted April 12, 2011 Hi, I have prestashop 1.2.5 version and dont have the archive frontcontroller.phpHi, I have the version 1.2.5 of prestashop. And this version does not have file FrontController. Know any other way? Thanks Link to comment Share on other sites More sharing options...
MrBaseball34 Posted April 12, 2011 Share Posted April 12, 2011 in 1.2.5, you modify header.php to load the one you want about line 9: /* CSS */ $css_files[_THEME_CSS_DIR_.'global_'.$smarty->lang_iso.'.css'] = 'all'; I am hopingthat that is correct. Link to comment Share on other sites More sharing options...
Malk Posted December 9, 2011 Share Posted December 9, 2011 hi nest, First I changedTools::addCSS(_THEME_CSS_DIR_.'global_es.css', 'all'); to Tools::addCSS(_THEME_CSS_DIR_.'global_'.Tools::getValue('isolang').'.css', 'all'); and I get this error that I'm explaining. I tried to put both instructions like this: Tools::addCSS(_THEME_CSS_DIR_.'global_es.css', 'all'); Tools::addCSS(_THEME_CSS_DIR_.'global_'.Tools::getValue('isolang').'.css', 'all'); i want to do exactly the same thing - would you be able to post the complete code that you changed, and to what you changed it to ? would be a great great help Link to comment Share on other sites More sharing options...
Malk Posted December 9, 2011 Share Posted December 9, 2011 actually don't worry i did it - really simple ! thanks Link to comment Share on other sites More sharing options...
larsky Posted March 19, 2012 Share Posted March 19, 2012 Well, i am trying to get this one fired up also using prestashop 1.3x. But if i add MrBaseball34's directions to modify header.php it still doesn't work at all. Site looks like the proper stylesheet couIdn't be found. I altered the name of the stylesheets to it's language... so for english i have "global_en.css" for german "global_de.css" etc. The line to change should be the mentioned line 9: /* CSS */ $css_files[_THEME_CSS_DIR_.'global_'.$smarty->lang_iso.'.css'] = 'all'; What's going wrong? Any help would be very much appreciated! Link to comment Share on other sites More sharing options...
larsky Posted March 21, 2012 Share Posted March 21, 2012 in 1.2.5, you modify header.php to load the one you want about line 9: /* CSS */ $css_files[_THEME_CSS_DIR_.'global_'.$smarty->lang_iso.'.css'] = 'all'; I am hopingthat that is correct. I Found the right way to (in my case) change background image on language choice voor PS V1.3x! In header.php find the following code on line 9: $css_files[_THEME_CSS_DIR_.'global_nl.css'] = 'all'; and replace with: $css_files[_THEME_CSS_DIR_.'global_'.Tools::getValue('isolang').'.css'] = 'all'; Now copy your global.css as many times as you have languages and rename them to (for example) "global_en.css" and "global_fr.css". Change your images accordingly for every language and you're done. Hope this helps anyone. If you now Link to comment Share on other sites More sharing options...
Frens Posted August 1, 2012 Share Posted August 1, 2012 (edited) Hello, must. necessarily the css file in the theme/css folder? I have a folder called contactform in the main-directory with teststyle_nl.css and teststyle_de.css and next code in the FrontController.php Tools :: addCSS (_contactform_dir_. 'teststyle_. Tools :: getValue (' isolang ').'. css', 'all'); but this does not work! Edited August 1, 2012 by Frens (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts