vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Programming Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=188)
-   -   [vBulletin|PHP]vBulletin options and conditionals (https://vborg.vbsupport.ru/showthread.php?t=134713)

Ziki 12-23-2006 10:00 PM

[vBulletin|PHP]vBulletin options and conditionals
 
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 .

Shazz 12-24-2006 05:56 PM

:confused:
Looks basic but understanding for me is slow :cross-eyed:

Ziki 12-24-2006 10:30 PM

What don't you understand?

DollarBill 01-13-2007 05:03 AM

I understand it all except the part where you find and identify which conditions can be used and where/when/etc.

Dismounted 01-13-2007 09:07 AM

[QUOTE=Ziki;1144546]This has to start with an if condition and end with an else.elseifs belong between those two./QUOTE]
No it doesn't. You can end with just an if or elseif. You only need to start with an if.

Ziki 01-14-2007 06:57 AM

Well yeah that's what iI said.

thincom2000 01-19-2007 03:25 PM

He just means you shouldn't put an elseif after an else. That would result in an 'UNEXPECTED ...' error.

Ziki 01-20-2007 01:32 PM

Yes that's what I said!

toonysnn 01-20-2007 03:34 PM

So would this work?
Code:

if ($vbulletin->options['show_motm'] == '1')
{
Yes
}
else
{
No
}

Or do we put the HTML in the place where code 1 and code 2 was?
Then, how do I install it? I am trying to make a Member of the Month code for my board and all this is confusing for a newbie to XML/Programming stuff for vBulletin Options.

Ziki 01-20-2007 03:40 PM

Yes but that is php code that is inserted into plugins

toonysnn 01-20-2007 03:57 PM

Ah ok, thanks for the info.

Ziki 05-16-2009 06:06 AM

Updated

imported_silkroad 06-17-2009 04:46 PM

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 (Post 1831400)
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 :cool:

Centrix 06-19-2009 01:33 PM

Isn't it supposed to be:
Code:

<if condition=" ">
// If.
<else />
<if confition=" ">
// Elseif
</if>
</if>


Ziki 06-20-2009 12:48 PM

No, that's not an else if just another condition inside else.

Budweiser 06-25-2009 09:13 AM

How do you define a "conditional" ?

Ziki 06-26-2009 09:57 AM

The code wrapped inside is only run if the conditions are true.

testbot 12-09-2009 03:03 PM

ok, this might be stupid but where's the "vBulletin option admincp"

Ziki 12-10-2009 12:53 PM

Enable debug mode and open vBulletin options :)


All times are GMT. The time now is 12:58 PM.

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.01265 seconds
  • Memory Usage 1,750KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (19)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete