Log in

View Full Version : Adding Settings to the AdminCP


UltraVR
06-01-2006, 01:57 PM
Hello,

I am working for an update to a product of mine, and I cannot figure out for the life of me how to add a setting to the AdminCP that is in the form of a dropdown menu. If anyone could please explain to me how this works, it'd be much appreciated.

For example, here is how to do it for a boolean setting:

<setting varname="bf_new_window" displayorder="10">
<datatype>boolean</datatype>
<optioncode>yesno</optioncode>
<defaultvalue>1</defaultvalue>
</setting>

How would I create a dropdown menu to allow users to choose a certain setting, though?

Alan @ CIT
06-01-2006, 07:06 PM
The easiest way is just to find a dropdown in the regular vBulletin options, click on "Edit" link next to it and copy the code :)

For example, the "Enable Forum Leaders" dropdown option in vB->Options has an option code of:

<select name=\"setting[$setting[varname]]\" tabindex=\"1\" class=\"bginput\">
<option value=\"0\" " . iif($setting['value']==0,'selected="selected"') . ">$vbphrase[no]</option>
<option value=\"1\" " . iif($setting['value']==1,'selected="selected"') . ">$vbphrase[yes]</option>
<option value=\"2\" " . iif($setting['value']==2,'selected="selected"') . ">$vbphrase[yes_but_disable_moderators]</option>
</select>

So essentially, you just have to write the <select> code yourself.

Thanks,
Alan.

UltraVR
06-02-2006, 03:00 AM
Thanks! I got that part to work, but now I have another problem.

I have added this setting to my product:

<setting varname="bf_new_window" displayorder="10">
<datatype>boolean</datatype>
<optioncode>yesno</optioncode>
<defaultvalue>1</defaultvalue>
</setting>

And in the actual code, I have this conditional:


if ($vbulletin->options['bf_new_window'] == 1)
{
Case 1
}
else
{
Case 2
}


The problem is that the code always ends up skipping case 1 and going with case 2. Is there some other way to use a boolean setting in a conditional?

Alan @ CIT
06-02-2006, 05:21 AM
That code should work fine. Are you using it within a function or class? If so, you might need to global $vbulletin.

Thanks,
Alan.

UltraVR
06-02-2006, 05:47 AM
Yes, it is within a function. That would explain why a similar conditional I used works elsewhere in the code. How do you global $vbulletin?

Alan @ CIT
06-02-2006, 05:57 AM
At the top of the function, put:

global $vbulletin;

This allows $vbulletin to be used within a function.

Thanks,
Alan.

UltraVR
06-02-2006, 06:52 AM
A million thanks to you! It worked, and you are now my hero.

Thanks,
A fellow Alan. :)

Adult SEO
06-02-2006, 12:08 PM
Hi!

I am trying to enable debug mode to be able to add settings via a vBulletin system. I added $debug=1; on top of the config.php file but I don't see any option to add settings.

Please help!

Kirk Y
06-02-2006, 01:44 PM
Enabling debug mode changed from $debug=1. Use the following in your config.php file:
$config['Misc']['debug'] = true;