View Full Version : Loading templates within plugins
drjink
07-03-2012, 09:04 AM
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?
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, 09: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:
$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.
Which hook are you using?
drjink
07-03-2012, 11: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.
Try parse_templates - it's called just before the header template is rendered.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.