everwonder Posted September 16, 2011 Share Posted September 16, 2011 Hi folks! Just a quick question - how do you change the order of flags? for example my site supports 3languages, and I want them to show up in specific order. I tried changing the id's in mysql and it all went bollocks. So is there a correct way to do it? Thanks! Also in which file to remove Link to comment Share on other sites More sharing options...
europaul Posted June 26, 2013 Share Posted June 26, 2013 Hello ! I have the same problem !!! Have you been able to solve it ? TXS ! Link to comment Share on other sites More sharing options...
PascalVG Posted June 26, 2013 Share Posted June 26, 2013 (edited) What languages do you support, what order are they now and what order do you want them?What PrestaShop version do you use?pascal <EDIT: when using features, this solution may give problems. For alternative, see post #23. pascal> General idea is like this. Override Language class:change+add functions://change this function:public static function getLanguages($active = true, $id_shop = false){if (!self::$_LANGUAGES)Language::loadLanguages();$languages = array();foreach (self::$_LANGUAGES as $language){if ($active && !$language['active'] || ($id_shop && !isset($language['shops'][(int)$id_shop])))continue;$languages[] = $language;}// example: start array {'English','Dutch','Greek'} N.B. elements of array are 0, 1, 2 !!// add these red lines (modify order as needed for you)Language::swapLanguages($languages,0,2); // in example: change 1st lang with 3rd: {'Greek', 'Dutch', 'English'}Language::swapLanguages($languages,0,1); // in example: change 1st lang with 2rd: {'Dutch', 'Greek', 'English'}// result: array contains {'Dutch', 'Greek', 'English'}return $languages;}//add this functionfunction swapLanguages(&$ary,$element1,$element2){$temp=$ary[$element1];$ary[$element1]=$ary[$element2];$ary[$element2]=$temp;}Hope this helps,pascal <EDIT: when using features, this solution may give problems. For alternative, see post #23. pascal> Edited September 26, 2013 by PascalVG When using features this may cause problems. See post #23 for alternative (see edit history) Link to comment Share on other sites More sharing options...
europaul Posted July 3, 2013 Share Posted July 3, 2013 Hi ! in which file i have to make that modification ? Im using prestashop 1.5.4 Now i have: en - es - ca And i need: es - ca - en Thanks ! Link to comment Share on other sites More sharing options...
PascalVG Posted July 4, 2013 Share Posted July 4, 2013 Hi Paul, You should make the changes in /classes/Language.php (actually you should override this file and do it there. See Prestashop documentation how you can do that: http://doc.prestashop.com/display/PS15/Overriding+default+behaviors If you can't find out how this works, just change it in the file above self, but don't forget you did it here (Make a big note!), because when upgrading PrestaShop this file will be overwritten, losing your modifications. pascal Link to comment Share on other sites More sharing options...
europaul Posted July 4, 2013 Share Posted July 4, 2013 Holly crow ! you are a genius ! That solution works at once. Thanks a lot Pascal ! I really aprecciate your help ! Link to comment Share on other sites More sharing options...
PascalVG Posted July 6, 2013 Share Posted July 6, 2013 You're welcome. Good luck with your shop! pascal Link to comment Share on other sites More sharing options...
europaul Posted July 6, 2013 Share Posted July 6, 2013 Im finishing to tune the shop but i need to add a back button in the product description page. The is suppose to look as the buy now button. Is possible to may be copy and paste the button code ? Also is a bit tricky about the translations, as its label should said: back in english, volver in spanish and catalan. Any ideas about hit new challenge ? Thanks ! Link to comment Share on other sites More sharing options...
PascalVG Posted August 31, 2013 Share Posted August 31, 2013 Hi Paul, Cleaning up my flagged messages: Did you find a solution for the back button already? If not, please let us know, pascal Link to comment Share on other sites More sharing options...
maca_eglarest Posted September 16, 2013 Share Posted September 16, 2013 I can't do this. I have 5 languages and prestashop 1.5.3. Where I have to write and what? Thank you a lot. Link to comment Share on other sites More sharing options...
PascalVG Posted September 16, 2013 Share Posted September 16, 2013 Hi maca, You have to make the changes in classes/Language.php, in the function getLanguages, as described in post #3, and add the swap function (also shown in post #3) What order are your flags now, and what order do you want them to be?? Then I can give you the swaps needed. Pascal Link to comment Share on other sites More sharing options...
maca_eglarest Posted September 16, 2013 Share Posted September 16, 2013 The currents languages are en-de-es-fr-ca and they must be es-en-de-fr-ca. Thanks, Pascal. If you could write the precise code, please, I will be eternally grateful. Link to comment Share on other sites More sharing options...
maca_eglarest Posted September 16, 2013 Share Posted September 16, 2013 Thank you very much. I just get it. Link to comment Share on other sites More sharing options...
PascalVG Posted September 16, 2013 Share Posted September 16, 2013 Hi maca, everything ok now? All working well? pascal Link to comment Share on other sites More sharing options...
maca_eglarest Posted September 17, 2013 Share Posted September 17, 2013 This question, yes. Although I have others like this. http://www.prestashop.com/forums/topic/275434-change-iso-code-for-flags/ Link to comment Share on other sites More sharing options...
PascalVG Posted September 17, 2013 Share Posted September 17, 2013 That one seems to be solved as well :-) pascal Link to comment Share on other sites More sharing options...
maca_eglarest Posted September 20, 2013 Share Posted September 20, 2013 Hello. Now I've noticed that changing the order of the flags everything is fine except the features of the products. The languages are listed in the original order, but under the new order of flags, and if I keep anything else, are recorded in the old order and are changed. What could I do? Link to comment Share on other sites More sharing options...
PascalVG Posted September 21, 2013 Share Posted September 21, 2013 Mace, not sure what you mean. Can you provide a link to a page so I can see what goes wrong? pascal Link to comment Share on other sites More sharing options...
maca_eglarest Posted September 21, 2013 Share Posted September 21, 2013 The problem is in the back office. When I am in catalog/products, this takes place in the tab features. If I change anything, the features are listed and stored in the original order of language, that is not current. So the features in Spanish appear under the English flag ... But if I don't change anything, th order in front office is ok, why? Link to comment Share on other sites More sharing options...
PascalVG Posted September 22, 2013 Share Posted September 22, 2013 Hmmm, maca, in my back office I don't see any problem. Would you mind to let me into your back office for a moment, so I can see directly in your shop where it goes wrong? If you want that: please make a temporary 'employee' with "admin" rights (Administration->Employee) then Send me a private message (PM) with the login and password (DON'T show it here, for obvious reasons... :-) ) let me know, pascal Link to comment Share on other sites More sharing options...
europaul Posted September 23, 2013 Share Posted September 23, 2013 Hi Paul, Cleaning up my flagged messages: Did you find a solution for the back button already? If not, please let us know, pascal Thanks Pascal. this post is solved. I cannot answer you before as i was out. Thanks a lot for your help ! Link to comment Share on other sites More sharing options...
PascalVG Posted September 24, 2013 Share Posted September 24, 2013 Hi maca, I checked your site and see what you mean. What happens is that the when the values of the features are displayed on the screen for editing (i.e. they are already saved one time in the database, and are no modified), they are coupled to the languages, using the ID of the languages: Sample: original Language order ,before we swap: ID - Language 1-EN 2-FR 3-ES After swap: 2-FR 3-ES 1-EN The value are 'matched with the ID's of the language, NOT the order of he language: What I believe is happening is, that Featurevalue 1 (When added the first time, originally FR), is now matched with language-ID 1 (ENG), and thus displayed first, so French Feature Value gets coupled to ENG language flag... I tried to fix it, but for now still in vein. I'll try to have another look when I have time. If you want to have a look yourself, look at codes like this: $feature_value->value[$language['id_lang']] = ... {foreach from=$available_features item=available_feature} {foreach from=$available_feature.featureValues item=value} etc. and files like Feature.php, FeatureValue.php, AdminFeaturesController.php. I expect the problem (and solution) to be in there somewhere... What might work is on this page only to have the languages UN-swapped. We then need to make a function GetLanguagesNoSwap or so and use this one to get the languages here. Not sure if that works, as it's a tab, not a separate page though, so there is a real possibility of mix-up! Other solution is maybe to turn it around: Only in the case where we show the Language selection block we use a swapped version of GetLanguages. We then DON'T change the normal Function GetLanguages as we did in my example, but for the blocklanguages module only we use a GetLanguagesSwapped instead. Back office stays the same then, fixing the problem with FeatureValues automatically... Well, I let you think with me about a solution. Think what would work for you. Best would be to fix the Featurevalues of course, but I didn't see an obvious solution yet... pascal Link to comment Share on other sites More sharing options...
PascalVG Posted September 26, 2013 Share Posted September 26, 2013 Hi maca, After struggling to just change the flags in the blocklanguages only, I found a solution on the TPL level: Take out all old changes (in language.php), as it mixed up things for back office->features, right? We will ONLY change the language order when choosing the flags in Front Office: Open file themes/<your theme folder>modules/blocklanguages/blocklanguages.tpl (if you don't have this file, copy it here from /modules/blocklanguages/blocklanguages.tpl) Here you'll see some code like this, at the top of the file: <!-- Block languages module --> {if count($languages) > 1} <div id="languages_block_top"> <div id="countries"> {* @todo fix display current languages, removing the first foreach loop *} {foreach from=$languages key=k item=language name="languages"} What we'll do is just re-arrange the order here in the array to display: <!-- Block languages module --> {if count($languages) > 1} {$lang_temp = $languages[0]} {$languages[0] = $languages[2]} {$languages[2] = $lang_temp} {$lang_temp = $languages[0]} {$languages[0] = $languages[1]} {$languages[1] = $lang_temp} <div id="languages_block_top"> <div id="countries"> {* @todo fix display current languages, removing the first foreach loop *} See? We applied the same swap as in the original post I made, but now at the tpl (display) level, instead of a higher level in the program, leaving the original order in place, causing no problems in back office anymore. Hope this helps! pascal Link to comment Share on other sites More sharing options...
maca_eglarest Posted September 26, 2013 Share Posted September 26, 2013 Thanks. It works!! For me it were: <!-- Block languages module --> {if count($languages) > 1} {$lang_temp = $languages[1]} {$languages[1] = $languages[2]} {$languages[2] = $lang_temp} {$lang_temp = $languages[0]} {$languages[0] = $languages[1]} {$languages[1] = $lang_temp} <div id="languages_block_top"> <ul id="first-languages" class="countries_ul"> {foreach from=$languages key=k item=language name="languages"} <li> Didn't you know something about this, http://www.prestashop.com/forums/topic/277235-visualization-and-linking-of-packages/ Pascal? Link to comment Share on other sites More sharing options...
PascalVG Posted September 26, 2013 Share Posted September 26, 2013 Hi maca, Good to hear it worked! I'll have a look at your other question tonight. pascal 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