matteosalvati Posted February 9, 2014 Share Posted February 9, 2014 i want change the order of flags in languages block. i want IT language in first position Can help me? Link to comment Share on other sites More sharing options...
CartExpert.net Posted February 10, 2014 Share Posted February 10, 2014 Hi. You either set up position changing (like it is for products, categories etc.) or you add a number prefix to the language, order them by name and strip the prefix. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
matteosalvati Posted February 10, 2014 Author Share Posted February 10, 2014 is not possible order languages by name Link to comment Share on other sites More sharing options...
CartExpert.net Posted February 10, 2014 Share Posted February 10, 2014 It is possible to order them by name, you need to change the SQL query in loadLanguage(). Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
matteosalvati Posted February 10, 2014 Author Share Posted February 10, 2014 excuse me but i'm not php expert , where is? Link to comment Share on other sites More sharing options...
CartExpert.net Posted February 10, 2014 Share Posted February 10, 2014 It is in 'classes/Language.php'. You'll need to override the class. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
vekia Posted February 10, 2014 Share Posted February 10, 2014 there is an sql query: $sql = 'SELECT l.*, ls.`id_shop` FROM `'._DB_PREFIX_.'lang` l LEFT JOIN `'._DB_PREFIX_.'lang_shop` ls ON (l.id_lang = ls.id_lang)'; it's necessary to add there ORDER BY clause, something like: $sql = 'SELECT l.*, ls.`id_shop` FROM `'._DB_PREFIX_.'lang` l LEFT JOIN `'._DB_PREFIX_.'lang_shop` ls ON (l.id_lang = ls.id_lang) ORDER BY l.name DESC '; 1 Link to comment Share on other sites More sharing options...
matteosalvati Posted February 10, 2014 Author Share Posted February 10, 2014 is possible to reverse the order? without renaming because i don't like "1. italian" the original order is EN FR IT, would be sufficient to reverse the order to: IT FR EN. which rule can be used? Link to comment Share on other sites More sharing options...
matteosalvati Posted February 10, 2014 Author Share Posted February 10, 2014 if add "ORDER BY l.name DESC;" rule, the site don't work Link to comment Share on other sites More sharing options...
CartExpert.net Posted February 10, 2014 Share Posted February 10, 2014 Post the function. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
matteosalvati Posted February 10, 2014 Author Share Posted February 10, 2014 public static function loadLanguages() { self::$_LANGUAGES = array(); $sql = 'SELECT l.*, ls.`id_shop` FROM `'._DB_PREFIX_.'lang` l LEFT JOIN `'._DB_PREFIX_.'lang_shop` ls ON (l.id_lang = ls.id_lang)'; ORDER BY l.name DESC; $result = Db::getInstance()->executeS($sql); foreach ($result as $row) { if (!isset(self::$_LANGUAGES[(int)$row['id_lang']])) self::$_LANGUAGES[(int)$row['id_lang']] = $row; self::$_LANGUAGES[(int)$row['id_lang']]['shops'][(int)$row['id_shop']] = true; } } Link to comment Share on other sites More sharing options...
vekia Posted February 10, 2014 Share Posted February 10, 2014 compare my code with yours you missed one important thing, you pasted order by clause outside the query. Link to comment Share on other sites More sharing options...
matteosalvati Posted February 10, 2014 Author Share Posted February 10, 2014 well, now work! i ordered by id_lang and now is the order that i want! public static function loadLanguages() { self::$_LANGUAGES = array(); $sql = 'SELECT l.*, ls.`id_shop` FROM `'._DB_PREFIX_.'lang` l LEFT JOIN `' . _DB_PREFIX_ . 'lang_shop` ls ON (l.id_lang = ls.id_lang) ORDER BY l.id_lang DESC' ; $result = Db::getInstance()->executeS($sql); foreach ($result as $row) { if (!isset(self::$_LANGUAGES[(int)$row['id_lang']])) self::$_LANGUAGES[(int)$row['id_lang']] = $row; self::$_LANGUAGES[(int)$row['id_lang']]['shops'][(int)$row['id_shop']] = true; } } more thanks Link to comment Share on other sites More sharing options...
matteosalvati Posted February 10, 2014 Author Share Posted February 10, 2014 a question, is possible order by "language_code"? adding line: ORDER BY l.language_code DESC i could add a number prefix in language code and order that, so I will not have to change the name. is correct? Link to comment Share on other sites More sharing options...
vekia Posted February 10, 2014 Share Posted February 10, 2014 sure you can, just use: ORDER BY l.language_code DESC; Link to comment Share on other sites More sharing options...
matteosalvati Posted February 10, 2014 Author Share Posted February 10, 2014 i can't modify name of language_code. I solved it differently, I added a column in the DB to called "ID_order", I assigned values corresponding to the order language. and after I added line ORDER BY l.ID_order ASC; Is correct? or adding a column could be a problem? 1 Link to comment Share on other sites More sharing options...
CartExpert.net Posted February 10, 2014 Share Posted February 10, 2014 (edited) Not as such, but every time you add a language you will need to set that value. Only if you've set it not to be NULL. Regards.Robin.The CartExpert Team Edited February 10, 2014 by CartExpert.net (see edit history) Link to comment Share on other sites More sharing options...
matteosalvati Posted February 10, 2014 Author Share Posted February 10, 2014 you're right. i can set in descending order, so when I add other languages, this will always be in last position because will have 0 as value Link to comment Share on other sites More sharing options...
vekia Posted February 10, 2014 Share Posted February 10, 2014 in my opinion it's enough, this solution will work, in fact, you probably don't add new language everyday so chaning value of order field in back office will not be a problem 1 Link to comment Share on other sites More sharing options...
CartExpert.net Posted February 10, 2014 Share Posted February 10, 2014 Yes, that's right Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
vvalen1977 Posted April 15, 2014 Share Posted April 15, 2014 hi, i tried change the query, but doesn't work, try cleaning the cache of prestashop, and the browser but not success. My query is correct: $sql = 'SELECT l.*, ls.`id_shop, l.name` FROM `'._DB_PREFIX_.'lang` l LEFT JOIN `'._DB_PREFIX_.'lang_shop` ls ON (l.id_lang = ls.id_lang) ORDER BY l.name'; But doesn't work, i tried to run this query directly in MYSQL and it worked, but in the PHP of prestashop don't worked. Can help me? Link to comment Share on other sites More sharing options...
matteosalvati Posted April 15, 2014 Author Share Posted April 15, 2014 This work: $sql = 'SELECT l.*, ls.`id_shop` FROM `'._DB_PREFIX_.'lang` l LEFT JOIN `'._DB_PREFIX_.'lang_shop` ls ON (l.id_lang = ls.id_lang)ORDER BY l.name DESC'; maybe you forgot DESC or ASC? Link to comment Share on other sites More sharing options...
vvalen1977 Posted April 15, 2014 Share Posted April 15, 2014 Thanks Matteos In MySQL if you not write nothing for default is ASC, anyway indicating ASC or DESC does not work, and order always by id_lang =( Link to comment Share on other sites More sharing options...
vekia Posted April 15, 2014 Share Posted April 15, 2014 the question is: where you changed it? and in addition, you use default theme? a lot of things depend on this Link to comment Share on other sites More sharing options...
vvalen1977 Posted April 20, 2014 Share Posted April 20, 2014 1) i changed this in: classes/Language.php 2) I am not using the default theme, but the query only existed in root directory, in my theme directory does not exist. =) Link to comment Share on other sites More sharing options...
vekia Posted April 20, 2014 Share Posted April 20, 2014 so i bet that your theme displays languages based on different queries, or even on different module. are you 100% sure that your theme uses default block languages block? and that .tpl file of this addon uses the same code as original one? Link to comment Share on other sites More sharing options...
vvalen1977 Posted April 21, 2014 Share Posted April 21, 2014 Wow!.... in the "classes" directory, there was another "classes", on each of them was a "Language.php" file. The change had to do in "classes/classes/Language.php". It works! thanks =) 1 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