Page 1 of 1

dropdown language

Posted: Sat Sep 08, 2018 8:18 am
by Timo
HI guys,

I use a select object to display month names in a select field and these must appear in the language of the user. How can I build the SQL statement so that by default the column mt_de is used, if French is set as language, the column mt_fr has to be displayed in the dropdown.

My months table
monthtable.JPG
If the user's language is French, this SQL has to be run:

Code: Select all

SELECT `mt_id`,`mt_fr` FROM `months_names`
In all other cases, this one.

Code: Select all

SELECT `mt_id`,`mt_de` FROM `months_names`
How to combine them?

Re: dropdown language

Posted: Sat Sep 08, 2018 9:32 am
by toms
Hi,

Since there is no Hash Cookie like #USER_LANGUAGE# which would simplify the SQL statement, you can(/need to) use an SQL join to retrieve a user's language.

Code: Select all

SELECT mt_id, 
       CASE 
         WHEN zzzzsys_user_id IS NULL 
               OR IFNULL(sus_language, '') <> 'French' THEN mt_de 
         ELSE mt_fr 
       END AS month_name 
FROM   months_names 
       LEFT JOIN zzzzsys_user 
              ON zzzzsys_user.zzzzsys_user_id = '#USER_ID#' 
zzzzsys_user_id IS NULL is for the globeadmin, since there is no zzzzsys_user_id in the zzzzsys_user table.


Wish list: Add a #USER_LANGUAGE# Hash Cookie.

Re: dropdown language

Posted: Wed Sep 12, 2018 4:17 am
by admin
.