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

Reply
 
Thread Tools Display Modes
  #1  
Old 07-01-2006, 04:12 AM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
This is the code I'm using:

PHP Code:
<fieldset>
<
legend>options</legend>
<
input type=\"hidden\" name=\"setting[$setting[varname]][]\" value=\"0\" />
<div class=\"smallfont\"><label for=\"option1\"><input type=\"checkbox\" name=\"setting[
$setting[varname]][]\" value=\"1\" id=\"option1\" " iif(bitwise($setting['value'], 1), 'checked="checked"') . " /><b>option 1</b></label></div>
<div class=\"smallfont\"><label for=\"option2\"><input type=\"checkbox\" name=\"setting[
$setting[varname]][]\" value=\"2\" id=\"option2\" " iif(bitwise($setting['value'], 2), 'checked="checked"') . " /><b>option 2</b></label></div>
</fieldset> 
What am I missing here? TIA for any help.
Reply With Quote
  #2  
Old 07-01-2006, 06:43 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Set the datatype to free.
Reply With Quote
  #3  
Old 07-01-2006, 02:40 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

Yeah I tried that, but then it won't save the status of the tickboxes. Same with Boolean.
Reply With Quote
  #4  
Old 07-03-2006, 02:54 AM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does anyone else have an idea?
Reply With Quote
  #5  
Old 07-03-2006, 03:19 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
if ($oldsetting['varname'] == 'yourvarname')
{
    
$bitfield 0;
    foreach (
$vbulletin->GPC['setting'][$oldsetting['varname']] AS $bitval)
    {
        
$bitfield += $bitval;
    }
    
$vbulletin->GPC['setting'][$oldsetting['varname']] = $bitfield;

Okay, now that it is an integer...

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>
^ should give you an idea
Reply With Quote
  #6  
Old 07-03-2006, 04:48 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

Thanks SirAdrian, I'll try that later.

Is there a reason that you've got the setting increments doubling?
Reply With Quote
  #7  
Old 07-03-2006, 06:59 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's a visual explanation...
Reply With Quote
  #8  
Old 07-03-2006, 07:27 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

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.
Reply With Quote
  #9  
Old 07-03-2006, 07:35 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have this in my PHP file where I use it
PHP Code:
    var $parsingLookup = array(
        
'html' => 1,
        
'smilies' => 2,
        
'bbcode' => 4,
        
'images' => 8,
        
'lines' => 16
    
); 
PHP Code:
$entryParsing convert_bits_to_array($blog->option('parse_entry'), $blog->parsingLookup); 
PHP Code:
        $entry['body'] = $parser->do_parse($entry['body'], 
            
$entryParsing['html'],
            
$entryParsing['smilies'],
            
$entryParsing['bbcode'],
            
$entryParsing['images'],
            
$entryParsing['lines'],
            
false
        
); 
^ an example

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).
Reply With Quote
  #10  
Old 07-03-2006, 07: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

Thanks again for all your help and the laugh , I've got everything working perfectly.
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 07:45 AM.


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.04487 seconds
  • Memory Usage 2,272KB
  • Queries Executed 11 (?)
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
  • (2)bbcode_code
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete