The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
How to make check-boxes for style selections in settings/options...
This wasn't especially difficult and doesn't rise to the level of being an article but I did quite a bit of searching and never saw it posted before.
Below is some code that will let you put a "style chooser" in Admin CP -> Settings -> Options (options for any mod you may create.) Previously I was asking users to manually enter styleids into a box if they wanted to enable or disable a style for a particular mod. Now they can easily select the style via a checkbox just like a usergroup name. In the Option Setup in the "Option Code" field enter this code: Code:
" . eval('$options = ""; foreach($vbulletin->stylecache[-1] AS $sss) { $styleid = $sss[0][styleid]; $style = $sss[0]; $options .= "\\t\\t<label for=\\"setting[$setting[varname]]$styleid\\" title=\\"usergroupid: $styleid\\"><input type=\\"checkbox\\" tabindex=\\"1\\" name=\\"setting[$setting[varname]]"."[]\\" id=\\"setting[$setting[varname]]$styleid\\" value=\\"$styleid\\"" . iif(strpos(",$setting[value],", ",$styleid,") !== false, \' checked="checked"\') . iif($vbulletin->debug, " title=\\"name="setting[$setting[varname]]"\\"") . " />$style[title]</label><br />\\n"; } return "<span class=\\"smallfont\\">\\n$options\\t</span>";') . "<input type=\"hidden\" name=\"setting[$setting[varname]][]\" value=\"-1\" /> The second part is you need to make a plugin on the hook admin_options_processing. In that plugin add the code: PHP Code:
And that is it- it will now give you a functioning option that looks like this: Oh in the back end calling the option like $vbulletin->options['varname'] will give you a comma separate string of styleids... so it might look like '1,2,3,5' if styleids 1, 2, 3, and 5 were selected. So if you need an array you will have to explode the data. This will only show non-mobile styles in newer versions of vBulletin and in most cases you don't need to worry about the mobile style anyway. If you did need to include the mobile styles you would have to edit this line in the option code: Code:
foreach($vbulletin->stylecache[-1] AS $sss) |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|