vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   vBulletin 4 template hooks usage example (https://vborg.vbsupport.ru/showthread.php?t=236900)

akanevsky 02-25-2010 08:40 PM

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.

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

Quote:

Originally Posted by Paul M (Post 1991552)
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

Quote:

Originally Posted by EquinoxWorld (Post 2212287)
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>


EquinoxWorld 06-25-2011 02:14 PM

Quote:

Originally Posted by Lancerforhire (Post 2212588)
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?

vbresults 06-25-2011 02:38 PM

Quote:

Originally Posted by EquinoxWorld (Post 2212602)
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.

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?


All times are GMT. The time now is 02:40 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01276 seconds
  • Memory Usage 1,747KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code_printable
  • (2)bbcode_html_printable
  • (2)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete