Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > Programming Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
[vBulletin|PHP]vBulletin options and conditionals
Ziki's Avatar
Ziki
Join Date: Nov 2005
Posts: 2,704

It appears that I am still alive

Show Printable Version Email this Page Subscription
Ziki Ziki is offline 12-23-2006, 10:00 PM

Want to bring your new product onto a new level and use vBulletin options as well?Here we go

To create a simple on/off option just enter the vBulletin option admincp.Now insert the values for your desired option,when you get to the type sellect boolean.I won't describe the other types here.Boolean returns values true/1 if the condition was correct and false/0 if it wasn't.

So the variable for a vb option is $vbulletin->options['OPTIONNAME'] in plugins and php code and for templates use $vboptions[OPTIONNAME] (notice,no apostrophes in templates).So to make a simple condition:

PHP Code:
if ($vbulletin->options['OPTIONNAME'])
{
echo 
"Correct";
}
else
{
echo 
"False";

If specifies the condition inside the brackets.If you use just the variable without the comparism sign (==) then it will think that you are checking if it is 1.

Oh I forgot,Yes = 1 and No = 0

Did you notice the else?That is executed if the condition is anything else than what we are checking with.But you can extend your code with another elseif

PHP Code:
if ($vbulletin->options['OPTIONNAME'] == '1')
{
echo 
"Correct";
}
elseif (
$vbulletin->options['OPTIONNAME'] == '0')
{
echo 
"False";
}
else
{
echo 
'This will never happen :)';

This was a very basic introduction into using PHP conditionals with vBulletin boolean (Yes/No) options .
Reply With Quote
  #12  
Old 01-20-2007, 03:57 PM
toonysnn toonysnn is offline
 
Join Date: Sep 2006
Location: Texas
Posts: 511
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah ok, thanks for the info.
Reply With Quote
  #13  
Old 05-16-2009, 06:06 AM
Ziki's Avatar
Ziki Ziki is offline
 
Join Date: Nov 2005
Posts: 2,704
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Updated
Reply With Quote
  #14  
Old 06-17-2009, 04:46 PM
imported_silkroad imported_silkroad is offline
 
Join Date: Dec 2003
Posts: 563
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, but how do we get the options to show up in the vB Options area of the AdminCP?

Thanks!

--------------- Added [DATE]1245270274[/DATE] at [TIME]1245270274[/TIME] ---------------

Quote:
Originally Posted by imported_silkroad View Post
Sorry, but how do we get the options to show up in the vB Options area of the AdminCP?

Thanks!
Nevermind... I figured it out.

Just use phpMyAdmin to create a new option in the settings table. Then, following the format in vBphrases, setting_name_of_your_db_option_title and setting_name_of_your_db_option_desc, create your phrases and you are done

Very nice
Reply With Quote
  #15  
Old 06-19-2009, 01:33 PM
Centrix Centrix is offline
 
Join Date: Sep 2005
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Isn't it supposed to be:
Code:
<if condition=" ">
// If.
<else />
<if confition=" ">
// Elseif
</if>
</if>
Reply With Quote
  #16  
Old 06-20-2009, 12:48 PM
Ziki's Avatar
Ziki Ziki is offline
 
Join Date: Nov 2005
Posts: 2,704
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, that's not an else if just another condition inside else.
Reply With Quote
  #17  
Old 06-25-2009, 09:13 AM
Budweiser's Avatar
Budweiser Budweiser is offline
 
Join Date: Jan 2008
Location: West Virginia
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How do you define a "conditional" ?
Reply With Quote
  #18  
Old 06-26-2009, 09:57 AM
Ziki's Avatar
Ziki Ziki is offline
 
Join Date: Nov 2005
Posts: 2,704
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The code wrapped inside is only run if the conditions are true.
Reply With Quote
  #19  
Old 12-09-2009, 03:03 PM
testbot testbot is offline
 
Join Date: Feb 2009
Posts: 373
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok, this might be stupid but where's the "vBulletin option admincp"
Reply With Quote
  #20  
Old 12-10-2009, 12:53 PM
Ziki's Avatar
Ziki Ziki is offline
 
Join Date: Nov 2005
Posts: 2,704
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Enable debug mode and open vBulletin options
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 12:39 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.05344 seconds
  • Memory Usage 2,291KB
  • Queries Executed 24 (?)
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)bbcode_code
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete