The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[HOW TO - vB4] Rendering templates and registering variables - a short guide
Introduction Starting with vB4, templates no longer get output using eval: PHP Code:
What's more: Variables and arrays from plugins that are executed on a page no longer can automatically be accessed in the templates of that page. They need to be registered first. . Basic functionality to render templates and register all variables/arrays you want to use inside PHP Code:
HTML Code:
{vb:raw my_var} {vb:raw my_array.key1} {vb:raw my_array.key2.key21} . . . Now, with the result of the rendering we can do several things: . Output template directly - custom pages PHP Code:
Note the second line, which is special for this type of use: PHP Code:
. Use a template hook PHP Code:
. Save into a variable for later use in custom template PHP Code:
PHP Code:
HTML Code:
{vb:raw my_template_rendered} . Save into an array and preregister to use in an existing/stock template PHP Code:
HTML Code:
{vb:raw my_insertvar} Essentially the same as what I put for preRegister would be the following two lines. They could replace the last two lines in the above php codebox: PHP Code:
. . Bonus track: ...whatever you do, cache your templates! Now you know how to get your templates on screen - once you succeeded in doing that, make sure to do it in a fast and ressource saving manner: make use of vB's template cache. To see whether your templates are cached or not, activate debug mode by adding $config['Misc']['debug'] = true;to your config.php (don't ever use that on your live site!). Among the debug info is a list of all templates called, and non-cached templates will show up in red. To cache your templates, add a plugin at hook cache_templates with the following code: PHP Code:
. Hope this helps! -cel ---- Addendum - There are now two blog posts on vb.com related to this topic: http://www.vbulletin.com/forum/entry...in-4-templates http://www.vbulletin.com/forum/entry...-4-based-files |
#32
|
||||
|
||||
In the plugin change "THEMEFLARE" to "TESTPAGE" ....
|
#33
|
|||
|
|||
Oops... that's not the problem, I've checked and it is "TESTPAGE", just a typing error on my part. Thanks for helping
Edit: I've updated my original post. |
#34
|
|||
|
|||
I seemed to have gotten it to work.
Downloads.php PHP Code:
DOWNLOADS_SHELL Code:
{vb:raw headinclude} {vb:raw header} {vb:raw navbar} {vb:raw HTML} {vb:raw footer} </body> </html> |
#35
|
|||
|
|||
thank you very much..
|
#36
|
|||
|
|||
Code:
eval( '$comment_boxes .= "' . fetch_template('App_Question_box') . '";' ) ; |
#37
|
||||
|
||||
Quote:
PHP Code:
|
#38
|
|||
|
|||
Alright, now I'm a bit stumped.
I cant seem to get the title of the page to register and it the pages don't work with subdomains. Anyone got a clue? |
#39
|
||||
|
||||
I'm not sure I understand your problem. From what I try to gather I am also not sure if you're asking anything that is in correspondence with the article.
|
#40
|
|||
|
|||
Alright, my bad. I got the title to work.
The bit about the subdomains does relate back to this. I've made a custom page using this How-To. When I load the page in the directory that global.php is in (the forum root directory) it loads absolutely fine. What I'm trying to do is made this template appear in a sub domain (stats.example.com) rather than being in the root (example.com) where the forums live. When I try running the code from the sub domain, it comes up and says that it doesn't know where "./global.php" is. I change this to be "http://example.com/global.php". That's fine, but then I get another error saying that it then can't find another .php file, etc, etc. I'm just trying to figure out how I can get my custom page to load on a sub domain. |
#41
|
||||
|
||||
Ahm, just like I suspected.
This tutorial is not about making custom pages, and has nothing to do with your problem. This one is. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|