The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
How To Include A Custom Template Via Plugins
This tutorial will show you how to include custom templates within your vBulletin pages using plugins. First of all, you need to create your custom template. Lets call this mytemplate for the sake of this tutorial. Once you have created your template, and decided where you would like to have it placed, you can put the template variable $mytemplate there. As vBulletin does not yet know what to do with this template variable, it simply ignores it when generating the page. Next you need to create the plugins for the template, so that vBulletin knows what to do with it. You need to create two plugins, one to include the template, and one to cache it (saves a query). The easiest way to do this, although not technically the best, is to create the first plugin in either the hook location global_start or parse_templates This allows the template to be used globally throughout your site. However, you can also create this plugin in the _complete hook for the location that you wish to have it displayed (eg postbit_complete memberinfo_complete etc). The content of this first plugin will be as follows: Code:
eval('$mytemplate = "' . fetch_template('mytemplate') . '";'); The second plugin is always placed in the hook location cache_templates as this is the one that literally does what it says on the tin. It caches the template, preventing an extra query on each page that it is included on. The content of this plugin will be as follows: Code:
$globaltemplates = array_merge($globaltemplates, array('mytemplate')); Congratulations, your custom template is now included on your site without the need for any code modifications, and is already up and running. If at any point you decide that you want to remove the custom template, either temporarily or permanently, you can simply disable the two plugins and it will again vanish. My personal preference is to use the parse_templates hook for the first plugin as this enables the template to be used on every page on your site so you can move it about without having to edit the plugin. It is also useful if you wish to have it included on two or more pages. The method explained in this tutorial is the exact same method as I have used for the following modifications: |
#42
|
|||
|
|||
Hi all,
I have tried this and it works good however it only works within vb if I try to use the same template in vba it does not? any help will be appreciated Product: vBulletin Hook Location: global_start Code:
eval('$adv_portal_rotating_articles = "' . fetch_template('adv_portal_rotating_articles') . '";'); |
#43
|
|||
|
|||
global_start is too early
try global_setup_complete instead |
#44
|
|||
|
|||
Hey ragtek,
Still not working if i use this $adv_portal_rotating_articles in forumhome or any vb page it works fine but not in vba --------------- Added [DATE]1249411354[/DATE] at [TIME]1249411354[/TIME] --------------- Quote:
it should be defined through CMPS CP |
#45
|
|||
|
|||
or also $GLOBALS[adv_portal_rotating_articles] should also work
|
#46
|
||||
|
||||
Quote:
Quote:
Quote:
Quote:
I can get the contents of my test template to show, but it escapes my quotes within my HTML, so no styling is applied. --------------- Added 12 Oct 2009 at 12:11 --------------- Here's the code that I used: 2 plugins: 1] location: "global_start" name: "test_template_plugin" with followign code: PHP Code:
name: "Cached - test_template" with followign code: PHP Code:
my template contents (test_template) (VERY simple) HTML Code:
<table class="test_template_table"> <tr> <td class="test_template_td"> Hi there! </td> </tr> </table> --------------- Added [DATE]1255400076[/DATE] at [TIME]1255400076[/TIME] --------------- I was trying to follow the advice of the first post that I quoted, and it just didn't work. I changed the first plugin to include the eval() code for my variable, and it worked properly. Sorry for the bother. |
#47
|
|||
|
|||
This is a best way to add a template to a product in vb4?
|
#48
|
|||
|
|||
Also would like to know if this article is still valid? Anyone can provide us with some confirmation please.
|
#49
|
||||
|
||||
No this is only valid for the 3.x series of vBulletin. Check the VB 4.x Articles section for more relevant articles.
|
#50
|
||||
|
||||
but why not working in STANDARD_REDIRECT template ? how can i do?
|
#51
|
||||
|
||||
I have tried everything you have provided to the very letter, and it simply doesn't work at all... the variable is always null when I call for it in the template.
I'm trying to add a custom template to the forumhome_forumbit_level1_post template. What am I doing wrong!? Here's how I have it set up: New Custom Template - title is: sponsorForumButtons Right now I just have it filled with "TESTING THE NEW TEMPLATE" I have added a new Plugin, which is active, in global_start (I've tried in forumdisplay_complete, forumdisplay_start, global_complete, all the forumhome hooks... I've tried every single hook location I could think of... none seem to work) This is the exact code of the Plugin: //Sponsor Forum Buttons eval('$sponsorForumButtons = "' . fetch_template('sponsorForumButtons') . '";'); Then in the forumhome_forumbit_level1_post template I have: $sponsorForumButtons Right where I want it to show up. No matter what I try the variable just doesn't show up... even if I EXPLICITLY set the variable in the forumdisplay_start (or any other) hook... shouldn't the global_complete hook be available to every template!? Even so, how is it that the variable is ALWAYS null? It seems like the variable will show up in the FORUMDISPLAY template, but if I put it into the forumhome_forumbit_level1_post template, the variable is inexplicably null. I have even tried to cache the template in cache_templates and parse_templates. That code looks like this: $globaltemplates[]='sponsorForumButtons'; NOTHING WORKS! I am having a nervous breakdown. Please save me from killing myself... |
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|