Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-01-2006, 01:57 PM
UltraVR's Avatar
UltraVR UltraVR is offline
 
Join Date: Feb 2005
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Adding Settings to the AdminCP

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:

PHP Code:
            <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?
Reply With Quote
  #2  
Old 06-01-2006, 07:06 PM
Alan @ CIT Alan @ CIT is offline
 
Join Date: Nov 2004
Location: South UK
Posts: 625
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:

Code:
<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.
Attached Images
File Type: jpg vboptions_edit_1.jpg (133.2 KB, 0 views)
Reply With Quote
  #3  
Old 06-02-2006, 03:00 AM
UltraVR's Avatar
UltraVR UltraVR is offline
 
Join Date: Feb 2005
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks! I got that part to work, but now I have another problem.

I have added this setting to my product:

PHP Code:
    <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:

PHP Code:
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?
Reply With Quote
  #4  
Old 06-02-2006, 05:21 AM
Alan @ CIT Alan @ CIT is offline
 
Join Date: Nov 2004
Location: South UK
Posts: 625
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That code should work fine. Are you using it within a function or class? If so, you might need to global $vbulletin.

Thanks,
Alan.
Reply With Quote
  #5  
Old 06-02-2006, 05:47 AM
UltraVR's Avatar
UltraVR UltraVR is offline
 
Join Date: Feb 2005
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #6  
Old 06-02-2006, 05:57 AM
Alan @ CIT Alan @ CIT is offline
 
Join Date: Nov 2004
Location: South UK
Posts: 625
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

At the top of the function, put:

PHP Code:
global $vbulletin
This allows $vbulletin to be used within a function.

Thanks,
Alan.
Reply With Quote
  #7  
Old 06-02-2006, 06:52 AM
UltraVR's Avatar
UltraVR UltraVR is offline
 
Join Date: Feb 2005
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

A million thanks to you! It worked, and you are now my hero.

Thanks,
A fellow Alan.
Reply With Quote
  #8  
Old 06-02-2006, 12:08 PM
Adult SEO's Avatar
Adult SEO Adult SEO is offline
 
Join Date: May 2006
Location: The Netherlands
Posts: 291
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
  #9  
Old 06-02-2006, 01:44 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Enabling debug mode changed from $debug=1. Use the following in your config.php file:
PHP Code:
$config['Misc']['debug'] = true
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:21 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04656 seconds
  • Memory Usage 2,270KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (1)postbit_attachment
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete