Ziki's Hideout~The Hideout From Reality~vBulletin Modifications and Hacks WEBSITE FOR SALE INCLUDING ALL HACKS,IF INTERESTED EMAIL TO ADMIN@ZIKIHIDEOUT.COM
Go Back   Ziki's Hideout~The Hideout From Reality~vBulletin Modifications > Webmaster Forum > Tutorials/Articles
Member Area Mods Register RSS Members List Search Today's Posts Mark Forums Read

Tutorials/Articles Programming,template and any other tutorials are located here.


Welcome to the Ziki's Hideout~The Hideout From Reality~vBulletin Modifications forums.

You can download free and paid vBulletin modifications,hacks and styles.You can even find vBulletin services,webmaster and coding help.

You are currently viewing our boards as a guest which gives you limited access to our modifications,hacks and other vBulletin resources.By joining our community, you agree to the forum rules and that you do own a valid vBulletin license

If you have any problems with the registration process or your account login, please contact us.

[How-To]Use conditionals in vBulletin

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old February 7th, 2007, 12:49 AM   #1 (permalink)
Ziki
Owner/Admin
Ziki's Avatar
 
Location: Slovakia
Age: 15
Posts: 242 -- Threads: 37
Total ZCredit: 3100
Rep Power: 10Ziki is on a distinguished road
Send a message via ICQ to Ziki Send a message via Skype™ to Ziki
Default [How-To]Use conditionals in vBulletin

One of the most basic tutorials but I haven't seen it here

So let's start off.Let's say you have an option called Enable hack that is an yesno code.So yes equals 1 and no equals 0.Then you have many options like free,textarea and many more.But this is just basic

Now to the ifs.The if syntax looks like this:
Code:
if ($condition == $somthing) { //execute }

So $condition is something we want to check for.In our case the vbulletin options condition is
Code:
$vbulletin->options['youroptionname']

where youroptionname is the var name you specified for your option.Now we want to check if the hack is enabled and if yes it will execute the code.Yes equals 1 remember?So the hack is set to yes.

Code:
if ($vbulletin->options['optionname'] == '1') { //execute }

The == is to compare.You can also use other comparing signs like > or <.


Now to the else

Lemme say we got one if conditions

Code:
if ($vbulletin->options['optionname'] == '1') { code 1 } else { code 2 }

So if the option equals 1, code 1 will be executed but if the option is everything else than 1, code 2 will be executed.

Elseif is the a hybrid.It combines the else and if statements:

So it starts with an if then follows an elseif statement that allows you to use an condition:

Code:
if ($vbulletin->options['optionname'] == '1') { code 1 } elseif ($vbulletin->options['optionname'] == '2') { code 2 } else { code 3 }

So if option is 1,code 1 will be executed,if option is 2 then code 2 will be executed and if it is everything else than that, code 3 will be executed.

Now IMPORTANT:

This has to start with an if condition and end with an else or elseif.It can't end with else and after elseif.

Hope you understood that.
Ziki is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 3rd, 2007, 10:34 PM   #2 (permalink)
Norman
Newbie
 
Location: [Italy]
Posts: 3 -- Threads: 1
Total ZCredit: 0
Rep Power: 7Norman is an unknown quantity at this point
Default Re: [How-To]Use conditionals in vBulletin

If can I ask..
Wich is the best way..

Code:
if ($vbulletin->options['optionname'] == '1') { code 1 } elseif ($vbulletin->options['optionname'] == '2') { code 2 }


Or..


Code:
if ($vbulletin->options['optionname'] == '1') { code 1 } if ($vbulletin->options['optionname'] == '2') { code 2 }

?

It's the same?
Norman is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 3rd, 2007, 10:52 PM   #3 (permalink)
Ziki
Owner/Admin
Ziki's Avatar
 
Location: Slovakia
Age: 15
Posts: 242 -- Threads: 37
Total ZCredit: 3100
Rep Power: 10Ziki is on a distinguished road
Send a message via ICQ to Ziki Send a message via Skype™ to Ziki
Default Re: [How-To]Use conditionals in vBulletin

It's the same but it's better to use elseif.Or use the switch function
Ziki is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 4th, 2007, 02:02 PM   #4 (permalink)
Norman
Newbie
 
Location: [Italy]
Posts: 3 -- Threads: 1
Total ZCredit: 0
Rep Power: 7Norman is an unknown quantity at this point
Default Re: [How-To]Use conditionals in vBulletin

Ok, thanks.
Norman is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is vBulletin (and modifications)? Ziki Pre-Sale Questions 1 April 14th, 2007 09:54 AM



Ziki's Hideout® All Rights Reserved 2004~2008
Powered by vBulletin® Copyright ©2000 - 2007, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0