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 |
#82
|
||||
|
||||
Why dont you use ad_footer_end hook?
|
#83
|
||||
|
||||
Quote:
Quote:
|
#84
|
|||
|
|||
Hi , I need for help
I created a template called: my_template and write "Hi" inside it. I want to get "Hi" in my FORUMHOME template so i made a plugin on global_start and put: PHP Code:
but nothing apper to me How to get my_template content in FORUMHOME or other template ??? |
#85
|
||||
|
||||
Quote:
PHP Code:
|
#86
|
|||
|
|||
Quote:
|
#87
|
|||
|
|||
I apologize for sounding so helpless, but what exactly do you do with templates, and where do you even go to put in the PHP code for them? I opened this article thinking it was about skins. I'll continue to look for a thread about skins, but all this sounds like it's also important on modifying vBulletin to suit your needs, so that's why I'm posting here.
|
#88
|
||||
|
||||
you also need to use right hook location!
For FORUMNOME probably will be forumhome_start or forumhome_complete Regards! |
#89
|
||||
|
||||
Is it possible to use a custom template and render it into a variable then use that variable in sending HTML email?
I'm trying to use the following PHP code: PHP Code:
Code:
{vb:raw username} {vb:raw bbtitle} {vb:raw homeurl} {vb:raw forumurl} {vb:raw hometitle} |
#90
|
||||
|
||||
thanks for this and hope that someday i can do this too alone and well enough of my own without error...but it's not quite easy at all to understand...just to be honest....
well i was about experimenting to show the Current Activity of the Currently Active Members above inside WGO BOX (by mouse hover to the username)....by adding the red code below Code:
<li> {vb:stylevar dirmark}<a class="username" href="{vb:link member, {vb:raw loggedin}}" title="{vb:rawphrase current_activity} {vb:raw loggedin.action} {vb:raw loggedin.where} ">{vb:raw loggedin.musername}</a>{vb:raw loggedin.invisiblemark}{vb:raw loggedin.buddymark}</li> PHP Code:
thanks and best regards to all |
#91
|
||||
|
||||
$loggedin.action or $loggedin.where are not valid PHP variables. I do not think that this is just a registering problem. You should probably open your own thread in the forums and explain exactly what and how you are trying to do.
|
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|