Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-20-2014, 03:22 PM
YannZeRookie YannZeRookie is offline
 
Join Date: Feb 2014
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default VBulletin Programming 101?

Hello,

We've been using VB for the past 6 months, and although we are quite happy with the feature set, we find it very difficult to expand, because of the lack of documentation.

I mean, is there anything beyond the 3 following links?

http://www.vbulletin.com/forum/blogs/joe-d/3932614-
http://www.vbulletin.com/docs/html/m...emplate_syntax
http://www.vbulletin.com/forum/blogs...-luke/3929999-

Doing reverse engineering, reading thousands lines of PHP code, performing tedious trial-and-error and pattern-matching programming, we were able to do a few things, though. For example, we developed a TeamSpeak plug-in that allows our users to create a TeamSpeak account from their VBulletin account and connect to TeamSpeak by a single click on our VBulletin site. So we know how to make a "product", create a template and insert it in hooks, code some PHP to support the product, make some SQL queries, etc. So we know how to do a few things, but this is far from being enough.

For example, how do I know which variables I can use when coding (or modifying) a template? Where are these documented? Or which code can I read to find out?

I have the feeling to be on a beach in a dark night with only a flash light in my hand. Very frustrating.

Example: I'd like to add some buttons in the starter_threadview_text1 hook. The AdminCP hook dialog has a nice box in which I am told to enter the variables that I would like to pass to my template as parameters (like userinfo or page). Sounds cool, but which variables can I use for God's sake? How can my template get something as simple as the current page's url?

Maybe I just completely missed some page or documentation from the start, and I will feel stupid when someone points me to it? Honestly I hope so, because at this point, I am just wasting my mental health double-guessing how the whole thing works and what I am allowed to do with it.

Thanks in advance for any pointers,

Yann
Les Scorpions du D?sert
Reply With Quote
  #2  
Old 04-20-2014, 03:47 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When I have used hooks, I have looked the hook location up in the templates (Search in Templates) to see what variables are available. For example, searching for "starter_threadview_text_1" gives me the display_contenttype_conversationstarter_threadview _Text template. It looks like the variable conversation is available there. Another thing I sometimes do is then search the files for that template to find out exactly what other variables may be available.
Reply With Quote
  #3  
Old 04-20-2014, 06:11 PM
YannZeRookie YannZeRookie is offline
 
Join Date: Feb 2014
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the fast response, I really appreciate it!

Yes, I can see the conversation={vb:raw conversation} in the template. This is the sort of guess work I've been doing.

And this precisely illustrates my point: where is the conversation variable described? If it's an array or an object, what are its fields? In which PHP code are they initialized?...
Reply With Quote
  #4  
Old 04-20-2014, 06:38 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by YannZeRookie View Post
And this precisely illustrates my point: where is the conversation variable described? If it's an array or an object, what are its fields? In which PHP code are they initialized?...
That is when I go searching in the files for the template name to see where it is rendered. Then, you can see the variable registered for use in the template and see all the code above there that defines the variable. But, searching for the template names is sometimes a bit tricky in vB5 (I wish I could smack whoever thought it was a good idea to write the code this way!). If I search for "conversationstarter_threadview" I find that the template name actually comes up in the template "widget_conversationdisplay". So then I search on "conversationdisplay" and get nowhere. And I'm out of time to continue on this (gotta run!), but you can see that finding the right word to search on to find where it gets defined is just darned tricky (read as "is just a fr*gging nightmare!!!").
Reply With Quote
Благодарность от:
tbworld
  #5  
Old 04-20-2014, 09:07 PM
YannZeRookie YannZeRookie is offline
 
Join Date: Feb 2014
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I know how you feel, that's exactly where I stand. It's like being in a rats maze. I hope when you come back you can give me some tips to understand how to follow the trail and dig out the info.

Again, with all my thanks for your help and your time!
Reply With Quote
  #6  
Old 04-21-2014, 02:08 AM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by YannZeRookie View Post
Thanks for the fast response, I really appreciate it!

Yes, I can see the conversation={vb:raw conversation} in the template. This is the sort of guess work I've been doing.

And this precisely illustrates my point: where is the conversation variable described? If it's an array or an object, what are its fields? In which PHP code are they initialized?...
Which template?

The variables are passed in from a number of different sources (sigh). The Frontend Controller (includes/vb5/frontend/controller ... since I can never find it), The API via direct call (vb/api), or a parent template i.e. widget/widget_activitystream:

Code:
{vb:template {vb:raw activityStreamTemplateName}, conversation={vb:raw node.content}, reportActivity=1, showChannelInfo=1}
Yes. It's a mess.
Reply With Quote
2 благодарности(ей) от:
Lynne, tbworld
  #7  
Old 04-21-2014, 12:03 PM
YannZeRookie YannZeRookie is offline
 
Join Date: Feb 2014
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Interesting, you gave me some hints which helped me putting the first pieces of the puzzle together. Thanks to you, I found the vB5_Template::render() method in vb/includes/vb5/template.php and made some successful tests. I immediately documented what I found and understood, you can read it here:

https://docs.google.com/document/d/1...it?usp=sharing

This will help me spread the knowledge to the other admins of our group. Again, I am not trying to find a fish to eat for one day, I am trying to learn fishing so I can feed myself for the rest of my life ;-)

If this can be useful to other VB people at the same time, all the better.

I look forward to your comments,

Thanks to everyone for your help!

Yann
Reply With Quote
2 благодарности(ей) от:
Lynne, tbworld
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 05:04 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.09522 seconds
  • Memory Usage 2,242KB
  • Queries Executed 13 (?)
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
  • (1)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (5)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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_postinfo_query
  • fetch_postinfo
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete