Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
Variable's For Beginners
melefire
Join Date: Dec 2005
Posts: 122

by melefire melefire is offline 20 Jun 2006

I hope that no one already wrote this.
Copyright 2006 MeleFire, You may not move this article from vBulletin.org

Description:
When writing hacks you may somtimes use the 'vBulletin Options' system, this system allows you to easily add your own options page for your hack. It also gives you variables that look like:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Those variables are good for conditional statments but if in the admincp your option requires the admin to enter text(not just yes or no) and then you attempt to put that variable inside a template so the text the admin entered will come up you will get the words:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So basically that dosn't work at all.

How to Fix the Problem:
Fixing the problem is not very hard. But you will need to have complete accses to the PHP page that calls the template. If you do not have a PHP page or a template visit this article, it tells how to make a custom vBulletin PHP/Template page.

Now you must open up your PHP page and find this code:*

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Add under:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Remember to replace myvariable with whatever you want your variable to be called and to replace youroptionname with what ever your option is called.
*If you did not find the first code you may just place the second code any where after the 'START MAIN SCRIPT'.

FAQ:
Q: Where is my option name?

A: On your options page for your hack(in DEBUG mode) click edit find varname: This is your option name.


Q: What version of vBulletin will this work for?

A: 3.5.0 - 3.6 Beta 2, but only 3.5.4 and 3.6 Beta 2 have been heavily tested.

----------
I hope this helped, please give me feedback!:classic:
Views: 2393
Reply With Quote
Comments
  #2  
Old 20 Jun 2006, 11:15
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Real name: Zachery Woods
Well, in the tempates you need to use $vboptions[foo] instead of $vbulletin->options[foo]. If you want to use $vbulletin->options[foo] in templates you need to use {$vbulletin-options['foo']} and all is well. The former ($vboptions[foo]) would be prefered in the templates for easy reading as well as figuring out where they come from.
__________________
Looking for ImpEx?
Reply With Quote
  #3  
Old 20 Jun 2006, 11:19
melefire's Avatar
melefire melefire is offline
 
Join Date: Dec 2005
opps oh well, this way works too though
__________________
Design Build Install - Custom Web Design and Software Installation

Reply With Quote
  #4  
Old 20 Jun 2006, 11:28
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Real name: Zachery Woods
I wanted to confirm some things before I posted more, so from marco and alan-cit from irc.

You should really refrence varibles instead of copying them.

$myvarible =& $vbulletin->options['foo'];

Since we just want to reassign it an easier to remember name, and since this I assume would be used just for an easier to read option, it will save on memory. If we needed to change $myvarible for some reason, like +1 we would change the original as well, in which case we would want to copy it
__________________
Looking for ImpEx?
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

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


New To Site? Need Help?

All times are GMT. The time now is 19:36.

Layout Options | Width: Wide Color: