[How-to] Add a multiselect field in vBulletin options
I wrote this article 'cause I didn't found anything else but it was needed for mod I wrote.
Before I start - will have to say this is an example for a forumchooser. In our product under options, create an option like this: PHP Code:
Ok, we finished our first part and need 2 new plugins. The first plugin we used is admin_options_print. PHP Code:
$array = construct_forum_chooser_options (0); $selected = explode (',', $setting['value']); $name .= "[]"; The 1st line are our options array, filled with information coming from the function "construct_forum_chooser_options(0)". If you wanna have your own, create an array with your options. 2nd line: our value (saved later in the options will implode by a comma like: 5,8,11,26,.. we need to explode this value to get the selected values back. 3rd line: this is needed for multiselect The next plugin is called: admin_options_processing. PHP Code:
Regards |
This is great. Thank you very much for sharing :)
Regards, Stoebi |
can this be used in the user cp > options to make a "forum chooser" and which hook should I use?
|
A setting with datatype "bitfield" can create a group of checkboxes (multiselection) in vBulletin Options.
|
1 Attachment(s)
I didn't mean a forumchooser (Selectrow) or a multiple checkbox.
See image for the "multiselect field" what I mean. |
The chooser code is great but i am unsure how to call it in a plug in, normally i'd have the user enter the forum id's and use something like $allowedforums = explode(",", $vbulletin->options['sens_forumid']);
if (in_array($threadinfo['forumid'], $allowedforums)) How do i use the information of the selected forums creating a multiselect like this? |
I believe what you are after is something this.
Code:
if(in_array($GLOBALS['forumid'], explode(',', $vbulletin->options['MY_OPTION_NAME']))) |
That works with the above?
|
It should, the code I provided, works in my mods that I have a forum chooser in options, via a multi select field.
|
Hmmm, i tried a variation of the code i provided and it didnt work, the code you provided gives an error
Quote:
Errrr.....ummmm, guess who added an extra F to his own IF function!!! My apologies! |
All times are GMT. The time now is 07:58 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 | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|