vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Loading templates within plugins (https://vborg.vbsupport.ru/showthread.php?t=285158)

drjink 07-03-2012 08:04 AM

Loading templates within plugins
 
Greetings,

so i have been testing around for a while but i can't seem to get it to work.
I want to load a template into a variable within a plugin. I know how to access plugin-variables within templates but i can't find anything about how to load the template contents within a plugin. Is that even possible?

kh99 07-03-2012 08:13 AM

There and article here on rendering templates: https://vborg.vbsupport.ru/showthread.php?t=228078 , I think that explains what you need.

drjink 07-03-2012 08:34 AM

Yes, i found that one too but it doesn't seem to work.
Here is the thing, lets say i got a template named "my_template" and i want to load it within the plugin. According to that article i would write into my plugincode:
Code:

$templater = vB_Template::create('my_template');
$rendered = $templater->render();

And assume that i now have the contents of that template in $rendered, but it doesn't seem to work that way.
What i get with that plugin activated is some missing things in my header, but no PHP error! I didn't even use the plugin any further, only those 2 lines of code activated screw someting up in the board.

kh99 07-03-2012 08:38 AM

Which hook are you using?

drjink 07-03-2012 10:42 AM

global_bootstrap_init_complete

I just changed to global_bootstrap_complete and it may just work...i think it does...

Edit: Nope...i mean ok it does obviously work now somehow, the template gets stored into the variable, BUT with that hook, i can not use it in the header anymore. With the other hook that worked fine.
I don't know which hook i should use, so that both works. Just some hook that is always there that i can use for that.

kh99 07-03-2012 11:43 AM

Try parse_templates - it's called just before the header template is rendered.


All times are GMT. The time now is 11:50 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.03915 seconds
  • Memory Usage 1,717KB
  • 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
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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