Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-29-2009, 09:54 PM
crkgb crkgb is offline
 
Join Date: Oct 2007
Posts: 237
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Creating a product - what variables are available?

I am trying to create a new product with its own plugins and templates. When I add a new plugin to my product, how do I know what objects are created and available, and what variables are set? The vBulletin manual states:
Quote:
When adding code to a plugin, you should bear in mind that your code will have access to all variables and classes that are exposed at the point where the hook is placed.
vBulltin API docs provide lots of info on classes themselves, but nothing on what is available at what point?
Reply With Quote
  #2  
Old 04-29-2009, 10:03 PM
j883376 j883376 is offline
 
Join Date: Mar 2005
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The product itself does nothing. It's just a container to your plugins. You have to look in each PHP file for the hook locations and then create a plugin which uses said hook. It will inject the code that you put into the plugin where you see ($hook= etc, etc)
Reply With Quote
  #3  
Old 04-29-2009, 10:16 PM
crkgb crkgb is offline
 
Join Date: Oct 2007
Posts: 237
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by j883376 View Post
The product itself does nothing. It's just a container to your plugins. You have to look in each PHP file for the hook locations and then create a plugin which uses said hook. It will inject the code that you put into the plugin where you see ($hook= etc, etc)
Thank you. Yes, I understand that the plugin will "replace" the corresponding hook in the php file with my plugin code. But before vBulletin loads that said file it also loads a number of others, where objects and variables are initialised, creating a working environment for my plugin. I am trying not to reinvent the bicycle by querying the database for the data that has been pulled already and is just sitting somewhere in an object I don't know about. That's what I am trying to figure out - how do I know what variables and objects are created by the time my hook is pulled up. I hope vBulletin provides some documentation on this and not just "go through the code" advice, although either one is appreciated.
Reply With Quote
  #4  
Old 04-29-2009, 10:28 PM
j883376 j883376 is offline
 
Join Date: Mar 2005
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You read the code. Honestly, that's what I've seen a lot of other people say to do. It's personally how I learned how to program for vBulletin. You need to see what's defined in the PHP file for whatever you're trying to do. For example, if you want to do something right before a post is accepted and parsed into the database, you look for the proper hook (They have pretty easy to understand names) and then put in your code in that hook. The proper classes and functions that you'll need will be there elsewhere in the file.

The API is handy because it tells you the arguments for the functions and such, but it's not going to tell you what's in each of the files.
Reply With Quote
  #5  
Old 04-29-2009, 10:30 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

vBulletin does not have some list somewhere that tells you exactly what has been defined already at every hook location. You need to look at the php page and see what has been defined already.
Reply With Quote
  #6  
Old 04-29-2009, 10:31 PM
j883376 j883376 is offline
 
Join Date: Mar 2005
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
vBulletin does not have some list somewhere that tells you exactly what has been defined already at every hook location. You need to look at the php page and see what has been defined already.
Beat you to it
Reply With Quote
  #7  
Old 04-29-2009, 10:34 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So you did!
Reply With Quote
  #8  
Old 04-29-2009, 10:37 PM
j883376 j883376 is offline
 
Join Date: Mar 2005
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
So you did!
At first when I saw people saying "just read the code", I thought it was some sort of condescending "ur a n00bz lol" thing, but then I realized that there's no way to really code anything without going through the PHP files.
Reply With Quote
  #9  
Old 04-29-2009, 10:43 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

'Reading' the code also helps to tell you the name of the variable you want to use ($group or $discussion for example) and tells you if some fields other than the fields in the table have already been 'calculated' or evaled for you. It really does help to find your hook in the code and look at the stuff around it.
Reply With Quote
  #10  
Old 04-29-2009, 11:00 PM
crkgb crkgb is offline
 
Join Date: Oct 2007
Posts: 237
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much guys!
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 09:52 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.04688 seconds
  • Memory Usage 2,252KB
  • Queries Executed 11 (?)
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)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)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
  • (10)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