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

Reply
 
Thread Tools
Variable's For Beginners
melefire's Avatar
melefire
Join Date: Dec 2005
Posts: 122

 

Show Printable Version Email this Page Subscription
melefire melefire is offline 06-19-2006, 10:00 PM

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:
Code:
$vbulletin->options[optionname]
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:
Code:
Array[optionname]
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:*
Code:
$navbits[$parent] =
Add under:
Code:
$myvariable = $vbulletin->options[youroptionname]
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:
Reply With Quote
  #2  
Old 06-20-2006, 10:15 AM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 06-20-2006, 10:19 AM
melefire's Avatar
melefire melefire is offline
 
Join Date: Dec 2005
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

opps oh well, this way works too though
Reply With Quote
  #4  
Old 06-20-2006, 10:28 AM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
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 02:36 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.09799 seconds
  • Memory Usage 2,223KB
  • Queries Executed 17 (?)
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
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (3)postbit
  • (4)postbit_onlinestatus
  • (4)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