Skip to main content
Topic: Select config not taking language into account? (Read 2078 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Select config not taking language into account?

I figured I'd add a little config to this mod I'm writing, but it doesn't seem to pick up on the language data?

Code: [Select]
function UAD_integrate_general_mod_settings(&$config_vars)
{
loadLanguage('UAD');

$config_vars = array_merge($config_vars, array(
array(
'select',
'UAD_location',
'name' => 'UAD_location',
'data' => array(
array('0', 'UAD_bottom_user_info'),
array('3', 'UAD_top_user_info'),
array('2', 'UAD_below_post'),
),
),
'test',
));
}

Code: [Select]
$txt['UAD_location'] = 'User agent display location';
$txt['UAD_bottom_user_info'] = 'Bottom of user info popup';
$txt['UAD_top_user_info'] = 'Top of user info popup (1.1 only)';
$txt['UAD_below_post'] = 'Below post, above signature';

Re: Select config not taking language into account?

Reply #1

I'd think you have to
Code: [Select]
global $txt;
....
array(0, $txt['UAD_location']),
....
etc in the arrays  ...  you defined a hard coded string as the value.

Re: Select config not taking language into account?

Reply #2

Well sure, but I figured I had to be doing something wrong. If that's the case I'd say it's kind of a bug/unexpected behavior because it's working different than the first UAD_location over there (not the 'name' one, which of course shouldn't do any such thing).

Edit: oh right, I just realized I was unclear. (Click the screenshot! ;)) The UAD_location is picked up just fine; it's the select options that aren't. Imo it should be either one way or the other, not a mix.
Last Edit: April 03, 2016, 02:54:27 pm by Frenzie

Re: Select config not taking language into account?

Reply #3

Anyway, I found an example of the correct syntax in ManageFeaturesController.php. I was flying a bit blind before because there wasn't anything relevant around the hook.

Code: [Select]
array('select', 'jquery_source', array('auto' => $txt['jquery_auto'], 'local' => $txt['jquery_local'], 'cdn' => $txt['jquery_cdn'])),

I thus adjusted the code as follows, because I noticed the version I cooked up based on Admin.template.php didn't save:

Code: [Select]
function UAD_integrate_general_mod_settings(&$config_vars)
{
global $txt; // need $txt 'cause loadLanguage only fills in the setting's name
loadLanguage('UAD');

$config_vars = array_merge($config_vars, array(
array(
'select',
'UAD_location',
'name' => 'UAD_location',
array(
'0' => $txt['UAD_bottom_user_info'],
'3' => $txt['UAD_top_user_info'],
'2' => $txt['UAD_below_post'],
),
),
'',
));
}

Everything's working as it should now.