View Full Version : vBulletin 4 template hooks usage example
akanevsky
02-25-2010, 08:40 PM
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.
Paul M
02-25-2010, 09:10 PM
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.
EquinoxWorld
06-24-2011, 05:12 PM
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?
vbresults
06-25-2011, 01:41 PM
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):
if (in_array(THIS_SCRIPT, array('register', 'payments'))) {
$template_hook['headinclude_javascript'] .= vB_Template::create('lancerforhire_paid_registrati on_head_include_script')->render();
}
The template lancerforhire_paid_registration_head_include_scrip t for reference:
<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('hi dden');
} else {
$('.post_registration_description').removeClass('h idden');
}
});
// -->
</script>
EquinoxWorld
06-25-2011, 02:14 PM
A plugin from my paid registration mod (hook is parse_templates):
if (in_array(THIS_SCRIPT, array('register', 'payments'))) {
$template_hook['headinclude_javascript'] .= vB_Template::create('lancerforhire_paid_registrati on_head_include_script')->render();
}
The template lancerforhire_paid_registration_head_include_scrip t for reference:
<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('hi dden');
} else {
$('.post_registration_description').removeClass('h idden');
}
});
// -->
</script>
Thank you so much for the reply. I'm almost there. Here's what I got ; I want to use this hook:
{vb:raw template_hook.forumhome_above_forums}
In a CMS html widget. I then created this plug in :
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:
{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?
vbresults
06-25-2011, 02:38 PM
Thank you so much for the reply. I'm almost there. Here's what I got ; I want to use this hook:
{vb:raw template_hook.forumhome_above_forums}
In a CMS html widget. I then created this plug in :
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:
{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 1309016499 at 1309016499 ---------------
Sorry, I meant forumhome_complete, not parse_templates.
EquinoxWorld
06-25-2011, 03:15 PM
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?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.