News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

admin config page : "error" showing when clicking on the help button

Started by Naytheet, September 29, 2023, 10:29:37 AM

Previous topic - Next topic

Naytheet

Hello,
	
$config_vars array_merge($config_vars, array(
	
	
array(
'text''Facebook_id''help' => $txt['socialLoginFacebookId_desc'])
	
));


-> why does it give me the string "error" instead of the text ? 'subtxt' works ok.
In me sanitas et robur

Diego Andrés

What is the error?
Did you add $txt to the globals?
Did you load your language file?

SMF Tricks - Free & Premium Responsive Themes for SMF.

Naytheet

Yes I did all that, everything works with 'subtext', and it doesn't with 'help'. Idk what the error is because it just popups 'error' instead of the text.

function naytheet_social_login_general_mod_settings(&$config_vars)
{
	
global 
$txt;

	
loadLanguage('NaytheetSocialLogin');

	
$config_vars array_merge($config_vars, array(
	
	
array(
'title''NaytheetSocialLoginTitle')
	
));
	
$config_vars array_merge($config_vars, array(
	
	
array(
'text''Facebook_id''help' => $txt['socialLoginFacebookId_desc'])
	
));
	
$config_vars array_merge($config_vars, array(
	
	
array(
'text''Facebook_secret''help' => $txt['socialLoginFacebookSecret_desc'])
	
));
	
$config_vars array_merge($config_vars, array(
	
	
array(
'text''Facebook_Long_Lived_Token''help' => $txt['facebookLongLivedToken_desc'])
	
));
	
$config_vars array_merge($config_vars, array(
	
	
array(
'text''LinkedIn_id''help' => $txt['socialLoginLinkedInId_desc'])
	
));
	
$config_vars array_merge($config_vars, array(
	
	
array(
'text''LinkedIn_secret''help' => $txt['socialLoginLinkedInSecret_desc'])
	
));

	
$config_vars array_merge($config_vars, array(
	
	
array(
'text''SL_pass''help' => $txt['socialLoginSubtext'])
	
));

	
// SL password will  only be generated once and for all
	
echo 
'<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>';
	
echo 
'<script type="text/javascript">
	
	
$(document).ready(function(){
	
	
	
if (!$("#SL_pass").val()) $("#SL_pass").val("' 
random_password(10) . '");
	
	
	
else $("#SL_pass").prop("disabled", true);
	
	
	
$("#SL_pass").css("color", "red");
	
	
});
	
</script>'
;
}
In me sanitas et robur

Diego Andrés

You need to use the integrate_helpadmin hook, and in your function load the language file again.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Sesquipedalian

Also:

1. The help strings in your language file should to be added to $helptxt, not $txt.

2. The values of the 'help' keys in your $config_vars should be the raw $helptxt keys, not the values of those strings.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Naytheet

I changed the var names
$helptxt['NaytheetSocialLoginTitle'] = 'Naytheet Social Login';

no chance with getting it working.

function naytheet_social_login_general_mod_settings(&$config_vars)
{
    global $txt, $helptxt;

    if (!isset($helptxt))
        $helptxt = array();

    call_integration_hook('integrate_helpadmin');

    loadLanguage('NaytheetSocialLogin');

    $config_vars = array_merge($config_vars, array(
        array('title', 'NaytheetSocialLoginTitle')
    ));
    $config_vars = array_merge($config_vars, array(
        array('text', 'Facebook_id', 'help' => $helptxt['socialLoginFacebookId_desc'])
    ));
    $config_vars = array_merge($config_vars, array(
        array('text', 'Facebook_secret', 'help' => $helptxt['socialLoginFacebookSecret_desc'])
    ));
    $config_vars = array_merge($config_vars, array(
        array('text', 'Facebook_Long_Lived_Token', 'help' => $helptxt['facebookLongLivedToken_desc'])
    ));
    $config_vars = array_merge($config_vars, array(
        array('text', 'LinkedIn_id', 'help' => $helptxt['socialLoginLinkedInId_desc'])
    ));
    $config_vars = array_merge($config_vars, array(
        array('text', 'LinkedIn_secret', 'help' => $helptxt['socialLoginLinkedInSecret_desc'])
    ));

    $config_vars = array_merge($config_vars, array(
        array('text', 'SL_pass', 'help' => $helptxt['socialLoginSubtext'])
    ));

    // SL password will  only be generated once and for all
    echo '<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>';
    echo '<script type="text/javascript">
        $(document).ready(function(){
            if (!$("#SL_pass").val()) $("#SL_pass").val("' . random_password(10) . '");
            else $("#SL_pass").prop("disabled", true);
            $("#SL_pass").css("color", "red");
        });
    </script>';
}


Error logs say stuff like Undefined array key "socialLoginLinkedInId_desc"
In me sanitas et robur

Naytheet

I tried the following :

	
$helptxt['socialLoginFacebookId_desc'] = 'a test';

	
$config_vars array_merge($config_vars, array(
	
	
array(
'text''Facebook_id''help' => $helptxt['socialLoginFacebookId_desc'])
	
));


And a caption appears but the message showing after a click on the caption is 'error'.
In me sanitas et robur

Sesquipedalian

I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Naytheet

In me sanitas et robur

Naytheet

ok guess what. I added $helptxt['socialLoginFacebookId_desc'] = 'Cf. la description du mod pour savoir comment l\'obtenir.' into the file Help.english.php in default/languages and it works. What the name of the file is supposed to be in my mod then?
In me sanitas et robur

live627

Quote from: Diego Andrés on September 29, 2023, 06:25:44 PMYou need to use the integrate_helpadmin hook, and in your function load the language file again.
This is for 2.1.x. The help popup should then be able to find your language string once you've added that hook.

Diego Andrés

Correct, the user hasn't added the hook. And $helptxt is not needed it can be just $txt, I have tested it.
However this is still the correct format, like Sesq pointed out.

Quote from: Sesquipedalian on September 30, 2023, 11:41:15 AM'help' => 'socialLoginFacebookId_desc'

SMF Tricks - Free & Premium Responsive Themes for SMF.

Diego Andrés

function naytheet_social_login_helpadmin() {
    loadLanguage('NaytheetSocialLogin');
}
$config_vars = array_merge($config_vars, array(
        array('text', 'Facebook_id', 'help' => 'socialLoginFacebookId_desc')
    ));
Code (NaytheetSocialLogin.english.php) Select
$txt['socialLoginFacebookId_desc'] = 'Help Text';

SMF Tricks - Free & Premium Responsive Themes for SMF.

Naytheet

🐌 gosh sorry, I thought calling the system integration hook would have done the trick.
In me sanitas et robur

Sesquipedalian

Quote from: Diego Andrés on September 30, 2023, 05:43:16 PMAnd $helptxt is not needed it can be just $txt, I have tested it.

The best practice is to use $helptxt, though.

If the requested $helptxt string can't be found, SMF will check $txt as a fallback. But this is meant only as a last ditch attempt to recover in case a mod developer screwed up. It is not intended to be done intentionally.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Naytheet

Personally idc, I haven't developed all the machine lol. I'll take it like a legacy stuff, I just hope it will be ok that way for the versions to come.
In me sanitas et robur

Advertisement: