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

Reply
 
Thread Tools Display Modes
  #1  
Old 02-25-2010, 08:40 PM
akanevsky akanevsky is offline
 
Join Date: Apr 2005
Posts: 3,972
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default vBulletin 4 template hooks usage example

Can somebody provide an example of injecting advanced html code into some template hook? By "advanced html code" I mean html code enhanced with special vBulletin 4 structures, such as {vb:raw somevar}, {vb:rawphrase somevar} and <vb:if condition="...">code</vb:if>.

Or you can point me to some mod that implements such injections.

Thanks.
Reply With Quote
  #2  
Old 02-25-2010, 09:10 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You cannot do that.

The best you could do is have it in another template, render that template, and add the result to the template hook.
Reply With Quote
  #3  
Old 06-24-2011, 05:12 PM
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Location: Naples
Posts: 354
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Paul M View Post
You cannot do that.

The best you could do is have it in another template, render that template, and add the result to the template hook.
Would you happen to know where I can find some documentation on what you just said. That's exactly what I need to do. I have something that goes into a hook in forum home. I want to be able to put that hook on any other template or in a widget; can i do that?
Reply With Quote
  #4  
Old 06-25-2011, 01:41 PM
vbresults vbresults is offline
 
Join Date: Apr 2009
Posts: 687
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by EquinoxWorld View Post
Would you happen to know where I can find some documentation on what you just said. That's exactly what I need to do. I have something that goes into a hook in forum home. I want to be able to put that hook on any other template or in a widget; can i do that?
A plugin from my paid registration mod (hook is parse_templates):
PHP Code:
if (in_array(THIS_SCRIPT, array('register''payments'))) {
    
$template_hook['headinclude_javascript'] .= vB_Template::create('lancerforhire_paid_registration_head_include_script')->render();

The template lancerforhire_paid_registration_head_include_scrip t for reference:
HTML Code:
<vb:if condition="!empty($vboptions['lancerforhire_paid_registration_jquery'])">
	<script type="text/javascript" src="{vb:raw vboptions.lancerforhire_paid_registration_jquery}"></script>
</vb:if>

<script type="text/javascript">
<!--
	$(document).ready(function() {
		if (THIS_SCRIPT == 'register') {
			$('.pre_registration_description').removeClass('hidden');
		} else {
			$('.post_registration_description').removeClass('hidden');
		}
	});
// -->
</script>
Reply With Quote
  #5  
Old 06-25-2011, 02:14 PM
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Location: Naples
Posts: 354
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lancerforhire View Post
A plugin from my paid registration mod (hook is parse_templates):
PHP Code:
if (in_array(THIS_SCRIPT, array('register''payments'))) {
    
$template_hook['headinclude_javascript'] .= vB_Template::create('lancerforhire_paid_registration_head_include_script')->render();

The template lancerforhire_paid_registration_head_include_scrip t for reference:
HTML Code:
<vb:if condition="!empty($vboptions['lancerforhire_paid_registration_jquery'])">
	<script type="text/javascript" src="{vb:raw vboptions.lancerforhire_paid_registration_jquery}"></script>
</vb:if>

<script type="text/javascript">
<!--
	$(document).ready(function() {
		if (THIS_SCRIPT == 'register') {
			$('.pre_registration_description').removeClass('hidden');
		} else {
			$('.post_registration_description').removeClass('hidden');
		}
	});
// -->
</script>
Thank you so much for the reply. I'm almost there. Here's what I got ; I want to use this hook:

Code:
{vb:raw template_hook.forumhome_above_forums}
In a CMS html widget. I then created this plug in :

Code:
if (in_array(THIS_SCRIPT, array('index'))) {
    $template_hook['forumhome_above_forums'] .= vB_Template::create('vbcms_widget_static_page')->render();
}
With product: vBulletin
hook location: Global Start
Execution order: 5

But when I place that hook in the widget , the output is still:

Code:
{vb:raw template_hook.forumhome_above_forums}
What am I missing?? Any information will be incredibly useful. Thanks.

P.S.: I can change the hook that is going to be used. Maybe I need to create a new hook to use in the widget?
Reply With Quote
  #6  
Old 06-25-2011, 02:38 PM
vbresults vbresults is offline
 
Join Date: Apr 2009
Posts: 687
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by EquinoxWorld View Post
Thank you so much for the reply. I'm almost there. Here's what I got ; I want to use this hook:

Code:
{vb:raw template_hook.forumhome_above_forums}
In a CMS html widget. I then created this plug in :

Code:
if (in_array(THIS_SCRIPT, array('index'))) {
    $template_hook['forumhome_above_forums'] .= vB_Template::create('vbcms_widget_static_page')->render();
}
With product: vBulletin
hook location: Global Start
Execution order: 5

But when I place that hook in the widget , the output is still:

Code:
{vb:raw template_hook.forumhome_above_forums}
What am I missing?? Any information will be incredibly useful. Thanks.

P.S.: I can change the hook that is going to be used. Maybe I need to create a new hook to use in the widget?
Try using the forumhome_complete hook, not global_start (which is deprecated in 4.x anyway).

--------------- Added [DATE]1309016499[/DATE] at [TIME]1309016499[/TIME] ---------------

Sorry, I meant forumhome_complete, not parse_templates.
Reply With Quote
  #7  
Old 06-25-2011, 03:15 PM
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Location: Naples
Posts: 354
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK made the change but still nothing. I think it has to do with the plug-in that controls the content that's going into that hook in forum home. Wouldn't I have to also render the template of the content that's going into the widget or vbcms_widget_static_page template?

Also cleared cache and cookies in case they were rendered in the cookies.

Any ideas?
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:05 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.04013 seconds
  • Memory Usage 2,244KB
  • 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
  • (6)bbcode_code
  • (2)bbcode_html
  • (2)bbcode_php
  • (4)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
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (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
  • 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