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 03-04-2016, 01:08 PM
robertw795 robertw795 is offline
 
Join Date: Feb 2016
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Finding the right hook(s) for plugin(s) in vBulletin 5.2.0

I am currently adding advertisements to a forum and I want to place an advertisement after every 5 posts in a thread. To do this I have to write a custom plug-in.

I used to have a similar custom plug-in in a vBulletin 3.8.5 forum which I wanted to use as a reference. I noticed that the hooks have changed over the years. At this point my problem is that I don't know what hook I have to use for my plug-in, as the hooks of 3.8.5 don't correspond to those of 5.2.0 anymore.

I'd like to ask you which hook I have to use for my plug-in. And in general, where to find documentation about hooks and their functionality for future reference.

Where can I find this?

Thanks in advance.
Reply With Quote
  #2  
Old 03-04-2016, 05:35 PM
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Location: Phoenix, Az. USA
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hooks have just been re-implemented in vb5. There are only two in 5.2.0 and they are pretty much for testing. The hook system is in it infancy on vb5.

I would add a template hook in the conversation display templates to accomplish what you're trying to do. The only problem with that is the modification won't survivr an upgrade and will need to be re-added which is really not that big of a deal. I have several on my site that I do it on every upgrade.
Reply With Quote
  #3  
Old 03-07-2016, 08:15 AM
robertw795 robertw795 is offline
 
Join Date: Feb 2016
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Replicant View Post
I would add a template hook in the conversation display templates to accomplish what you're trying to do.
Hello,

Thanks for your reaction.
I've managed to display my plug-ins custom template below the reaction to a topic form using the conversation_below_entry hook location.

Now I want to display it inbetween the posts, so what I want to do is fetch the number of the posts in the topic, and place my custom template after every 5. Is it possible to write a custom hook location for this?
Reply With Quote
  #4  
Old 03-07-2016, 01:20 PM
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Location: Phoenix, Az. USA
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

From the VB5 manual

{vb:hook}
Code:
{vb:hook} is used for including templates hooks in current template.

Parameter Position	Parameter Name	Type	Required	Description
1	hook	string	Yes	The name of the template hook
Code:
{vb:hook test}
There is also {vbhp} available which provides for a limited amount of php functions in you template code.

Code:
{vb:php}
{vb:php} is used to run allowed php functions during the execution of a template.

Parameter Position	Parameter Name	Type	Required	Description
1	function name	string	Yes	The name of the function
2...∞	string[, ...]	compiable code	No	Arguments of the function
Code:
{vb:set test, {vb:php implode, ',', {vb:raw variable}}}
PHP Equivalent:
<?php 

$test = implode(',', $variable);
Allowed functions:
implode()
explode()
array_merge()
array_intersect()
array_intersect_key()
array_keys()
array_push()
array_pop()
array_shift()
array_unshift()
array_unique()
array()
current()
str_repeat()
str_pad()
strip_tags()
strtolower()
strtoupper()
trim()
substr()
vbstrtolower()
For more info on the VB5 template syntax, go here.

This is too funny. -->> {vbhp}
Reply With Quote
  #5  
Old 03-08-2016, 07:03 AM
robertw795 robertw795 is offline
 
Join Date: Feb 2016
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, I've got all the information I need now.
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 06:34 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.03657 seconds
  • Memory Usage 2,200KB
  • 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
  • (2)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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
  • 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