Quote:
Code:
$myvar = $templater->render(); should be this: Code:
$myvar .= $templater->render(); |
I'm struggling with getting data from a variable into one of the stock templates. Here's what I've done:
Created a custom plugin with the hook location set to "global_start": $roscohtml = "<div>HELLO WORLD!</div>"; error_log($roscohtml); vB_Template::preRegister('header',array('roscohtml '=>$roscohtml)); Then I customized the header template to contain this: <div class="above_body"> <!-- closing tag is in template navbar --> <div>test before</div> {vb:raw roscohtml} <div>test after</div> Unfortunately the variable isn't being output. I do see the contents in the error log, so I know it's firing. Any tips? Thanks, Rosco --------------- Added [DATE]1302039172[/DATE] at [TIME]1302039172[/TIME] --------------- OK, I think I found the problem - the global_start hook is not the right place for this to live. I moved my code to the parse_templates hook and the data is now available. Is there a document which outlines the best way to leverage the hooks, or at least where each is called in the flow? Rosco |
as templates no longer get output using eval
i tried to change it but seems not working. can anyone help me with this code? PHP Code:
|
<a href="https://vborg.vbsupport.ru/showpost.php?p=2180014&postcount=151" target="_blank">https://vborg.vbsupport.ru/showp...&postcount=151</a>
|
I hoping this isn't too far off topic bt if possible I think it would make a good addition to the article...
What if I want to override an existing template with a new template. Basically ignore whatever is in a given template and render a new template, and copy the new template to the old template? Is that possible? I've tried stuff like: Code:
$templater = vB_Template::create('my_new_template'); Is what I'm asking possible? Seems like it should be... Any input would be appreciated. |
Yes, it can be done easily, if what you are wanting is what I understand it to be. As an example, here is what I did for that:
Code:
$templater = vB_Template::create('boofo_forumhome_event'); |
Great, Thanks Boofo!
It might be worth mentioning for anyone else- you have to register any variables used to the ORIGINAL template (the one you are overriding) not the new template... At least that's the only way it's working for me. (On parse_templates hook) |
Are you sure? I used the same variables when I did it but I would think you only need to pre-register the variables you are going to use, not the other way around.
I did the above code in forumhome_start. Did you try the process_templates_complete hook? |
Maybe I didn't explain it right... in your example registering callink and the others to boofo_forumhome_event didn't do anything for me- I had to preRegister them to forumhome_event for them to work. I tried both parse_templates and process_templates_complete hooks.
To me it makes sense since the forum thinks it's outputting forumhome_event, and this is confirmed by viewing template names in the HTML source code. |
Well, yes and no. Since I did it in the forumhome_start hook, it needed those pre-registered for my new template. As long as the variables are good at that hook, then it will work the way I did it.
The forumhome doesn't care about the old template as long as I pre-register everything for my new template. Doing it in the parse_templates hook might be why it didn't work for you with your code. You would have to check whether whatever variables you are pre-registering have already been validated at whatever hook you are using. Now I'm getting confused. And it hurts! LOL |
All times are GMT. The time now is 06:54 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 | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|