The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Create checkbox group at your hack's options (usergroup selection for example)
Hello. In this article I will show how to create a checkbox group in your hack's options. It's easy. Just do the following: 1. Create an option. Datatype validation type = free. 2. Enter the following code to Option code: Code:
" . eval('$options=""; $fritems = array( "Test1Code" => "Test option checkbox", "Test2Code" => "Another test option checkbox", ); foreach($fritems AS $fritem_id => $fritem_name) { $options .= "\\t\\t<label for=\\"setting[$setting[varname]]$fritem_id\\" title=\\"item id: $fritem_id\\"><input type=\\"checkbox\\" tabindex=\\"1\\" name=\\"setting[$setting[varname]]"."[]\\" id=\\"setting[$setting[varname]][$fritem_id]\\" value=\\"$fritem_id\\"" . iif(strpos(",$setting[value],", ",$fritem_id,") !== false, \' checked="checked"\') . iif($vbulletin->debug, " title=\\"name="setting[$setting[varname]]"\\"") . " />$fritem_name</label><br />\\n"; } return "<span class=\\"smallfont\\">\\n$options\\t</span>";') . "<input type=\"hidden\" name=\"setting[$setting[varname]][]\" value=\"-1\" /> 4. Now create a admin_options_processing hook with the following code: PHP Code:
5. That's all. Now $vbulletin->settings['my_setting_name'] will be a string like "Test1Code,Test1Code" depending on what user checked at options page. A little moment on option text localization. Instead of PHP Code:
PHP Code:
Code:
<phrasetype name="vBulletin Settings" fieldname="vbsettings"> <phrase name="my_setting_phrase_name1" date="1218041520" username="FractalizeR" version=""><![CDATA[Test option checkbox]]></phrase> <phrase name="my_setting_phrase_name2" date="1218040714" username="FractalizeR" version=""><![CDATA[Another test option checkbox]]></phrase> </phrasetype> Code:
" . eval('$options =""; foreach($vbulletin->usergroupcache AS $usergroupid => $usergroup) { $options .= "\\t\\t<label for=\\"setting[$setting[varname]]$usergroupid\\" title=\\"usergroupid: $usergroupid\\"><input type=\\"checkbox\\" tabindex=\\"1\\" name=\\"setting[$setting[varname]]"."[]\\" id=\\"setting[$setting[varname]]$usergroupid\\" value=\\"$usergroupid\\"" . iif(strpos(",$setting[value],", ",$usergroupid,") !== false, \' checked="checked"\') . iif($vbulletin->debug, " title=\\"name="setting[$setting[varname]]"\\"") . " />$usergroup[title]</label><br />\\n"; } return "<span class=\\"smallfont\\">\\n$options\\t</span>";') . "<input type=\"hidden\" name=\"setting[$setting[varname]][]\" value=\"-1\" /> |
#2
|
|||
|
|||
Just what i been looking for, shame I havent got a clue..lol..
cool tut tho' |
#3
|
|||
|
|||
Can you provide a screenshot of how this would look?
|
#4
|
||||
|
||||
Attached to post
|
#5
|
||||
|
||||
/bookmarked
this is handy to have! |
#6
|
||||
|
||||
Fractalizer, very nice! I am wondering however why you don't just loop through each usergroup and call vbulletin's print_checkbox_row() function to handle the checkbox creation. It's located within adminfunctions.php
|
#7
|
||||
|
||||
I am not sure May be because this method was extracted from one hack a long time ago. And after some time I extended it a bit and decided to publish a how-to.
|
#8
|
||||
|
||||
Thanks for this tutorial.
in step 4 i.e. PHP Code:
I also wanted to know how to use this option code bitfield:nocache|allowedbbcodesfull This bitfield type code automatically generates a set of check boxes of allowed bbcodes to choose from. Now how to implement onto our page. Thank you |
#9
|
||||
|
||||
my_setting_name is the setting name you provided when creating setting. As for bitfield - I am not sure it is supported. Where is this example from?
|
#10
|
||||
|
||||
thanks for your reply !
alright so $settings['my_setting_name'] is the field setting name, fine. 1. And in the option code I see "setting[$setting[varname]", does varname needs to be replaced by something ? 2. How do I check for the checked options from the php page ? Like for boolean we do :- PHP Code:
3. umm.. not sure what you mean by bitfield supported. See in admincp->Social Group Options and Album Options and Visitor Message options. They all have a setting of "Allowed BBCODES", their option code is set to bitfield:nocache|allowedbbcodesfull and it automatically outputs a set of checkboxes of bbcodes. I did the same and it works but as in my 2nd ques, how do I check it ? Thank you |
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|