Jump to content

Language order


Recommended Posts

  • 2 years later...
HI
Any ideas how to order language icons in prestashop store?
Thanks


Hi,
probably you have solved it yourself, but in case somebody else needs a solution, this can be useful:
in the /module/blocklanguages/blocklanguages.php file put
function cmp($a, $
{
 //language iso_code in the desired order:
 $new_order = array("fr", "es", "en", "de");
 foreach($new_order as &$value)
 {
   if ($a["iso_code"]==$value) return -1;
   if ($b["iso_code"]==$value) return 1; 
 }
}
usort($languages,"cmp");



right before the following line:

$smarty->assign('languages', $languages);



I tested it in prestashop 1.3.5

Cheers,
Laci

  • Like 1
Link to comment
Share on other sites

  • 8 months later...
  • 7 months later...
  • 5 months later...
  • 4 months later...
  • 5 months later...

For PS 1.5.4.1 I override the following class in classes/Language.php:

   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;
        }

        usort($languages, function($a, $
        {
            //language iso_code in the desired order:
            $new_order = array("es", "en");
            foreach($new_order as &$value)
            {
                if ($a["iso_code"]==$value) return -1;
                if ($b["iso_code"]==$value) return 1;
            }
        });

        return $languages;
    }
  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...