PDA

View Full Version : tis the season to help a newbie! ;p


Chronique
12-22-2006, 04:31 PM
I apologize in advance if this is not the proper forum to ask this question in. I am a major newbie to all of this and I have figured out much more than I ever thought I would over the last few days! ;)

I found this great tutorial from Petra (pasted below), but I am so clueless I still have some basic questions:

-where am i placing the template in order for these plugins to work?
If the template exists as a saved template in my admin area, do i just replace mytemplate with the name of the one I am using....or is there more to it than that?
-re execution order in create new plug in, would the first below be 1 and the second be 2? the default is 5 and i want to be sure.

I appreciate the help! Happy Holidays everyone!

Kim


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:eval('$mytemplate = "' . fetch_template('mytemplate') . '";');This tells it that when it comes across $mytemplate, it is to fetch the template mytemplate and include it there. This plugin can be named anything that you want, and should be set to active.

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:$globaltemplates = array_merge($globaltemplates, array('mytemplate'));This tells it to add mytemplate to the global templates array, which ensures that everywhere that it is used, it is cached. Again, this plugin can be named anything that you want, but not the same as the first one, and should be set to active.


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:
Additional Navbar In Footer (https://vborg.vbsupport.ru/showthread.php?t=117991)
Right side column on forum home only (https://vborg.vbsupport.ru/showthread.php?t=117989)
Left side column on forum home only (https://vborg.vbsupport.ru/showthread.php?t=117988)