The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Tickbox vB Option Code
Trying to setup a vb option setting with tick boxes in it. I took some code from a setting that already had them and implemented it into my own, but now I'm getting this wacky error:
Code:
Fatal error: Unsupported operand types in \includes\adminfunctions_options.php on line 229 PHP Code:
|
#2
|
||||
|
||||
Set the datatype to free.
|
#3
|
||||
|
||||
Yeah I tried that, but then it won't save the status of the tickboxes. Same with Boolean.
|
#4
|
||||
|
||||
Does anyone else have an idea?
|
#5
|
||||
|
||||
You need to convert the data to an integer first, then upon retrieving the data, check to see the individual values. Bitfields make it easy....
admin_options_processing hook: PHP Code:
option eval code Code:
<fieldset> <legend>$vbphrase[yes] / $vbphrase[no]</legend> <input type=\"hidden\" name=\"setting[$setting[varname]][]\" value=\"0\" /> <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"> <tr valign=\"top\"> <td class=\"smallfont\" nowrap=\"nowrap\"> <label for=\"yoursetting1\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"yoursetting1\" value=\"1\" tabindex=\"1\" " . iif(bitwise($setting['value'], 1), 'checked="checked"') . " />Ratings</label><br /> <label for=\"yoursetting2\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"yoursetting2\" value=\"2\" tabindex=\"1\" " . iif(bitwise($setting['value'], 2), 'checked="checked"') . " />Entries</label><br /> <label for=\"yoursetting4\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"yoursetting4\" value=\"4\" tabindex=\"1\" " . iif(bitwise($setting['value'], 4), 'checked="checked"') . " />Last Entry</label><br /> <label for=\"yoursetting8\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"yoursetting8\" value=\"8\" tabindex=\"1\" " . iif(bitwise($setting['value'], 8), 'checked="checked"') . " />Comments</label><br /> <label for=\"yoursetting16\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"yoursetting16\" value=\"16\" tabindex=\"1\" " . iif(bitwise($setting['value'], 16), 'checked="checked"') . " />Last Comments</label><br /> <label for=\"yoursetting32\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"yoursetting32\" value=\"32\" tabindex=\"1\" " . iif(bitwise($setting['value'], 32), 'checked="checked"') . " />Views</label><br /> <label for=\"yoursetting64\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"yoursetting64\" value=\"64\" tabindex=\"1\" " . iif(bitwise($setting['value'], 64), 'checked="checked"') . " />Category</label><br /> <label for=\"yoursetting128\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"yoursetting128\" value=\"128\" tabindex=\"1\" " . iif(bitwise($setting['value'], 128), 'checked="checked"') . " />Mass Moderation</label><br /> </td> </tr> </table> </fieldset> |
#6
|
||||
|
||||
Thanks SirAdrian, I'll try that later.
Is there a reason that you've got the setting increments doubling? |
#7
|
||||
|
||||
Here's a visual explanation...
|
#8
|
||||
|
||||
Ha ha -- thanks SirAdrian, that makes sense.
One final question before the thread can be put to bed: how do I call the option? The typical $vbulletin->options[varname] returns an array, go figure, but I'm not sure what values to use for each bit. |
#9
|
||||
|
||||
I have this in my PHP file where I use it
PHP Code:
PHP Code:
PHP Code:
For the values, go up by multiples of two (binary!), then make sure the values you use matchup with an array (in my case, $blog->parsingLookup). |
#10
|
||||
|
||||
Thanks again for all your help and the laugh , I've got everything working perfectly.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|