PDA

View Full Version : I added a new template but how do I use it?


okgaz
07-24-2007, 04:24 PM
Hi,

I made a new template from my admin panel + I want to include it in my header. All the other templates seem to be included in one another just by adding "$templatename" but it doesn't work for the one I created. Do I need to do something to assign a "$name" to it?

Thanks!

-Gaz

davidw
07-24-2007, 05:10 PM
You'll need to do these things:
1) Create your template, templatename, which you've already done and
2) Create 2 plugins
Go to your admincp => Plugins & Products => Add New Plugin =>

Plugin 1
Product - vbulletin
Hook Location - cache_templates
Title - Title of Plugin 1
Plugin PHP Code - $globaltemplates[] = 'templatename';

and

Plugin 2
Product - vbulletin
Hook Location - global_start
Title - Title of Plugin 2
Plugin PHP Code global $db, $vbulletin;
eval('$templatename .= "' . fetch_template('templatename') . '";');

okgaz
07-24-2007, 05:40 PM
Hi David. Thanks for your help!

Using your method it now shows up on the forum pages.

It is my ibproarcade pages I want it show up on though + it doesn't seem to work on those. Do you know of anything I can do to fix that?

-Gaz

davidw
07-24-2007, 05:42 PM
You may need to request help under that modification's support forum (https://vborg.vbsupport.ru/forumdisplay.php?f=170).

funrun
07-25-2007, 03:14 AM
David, your plugin advice got my added template to show up too, yet created an odd problem that I'm stuck on. What I did was literally cut a section of code (my custom navbar) that I had duplicated in the SHOWTHREADS, FORUMDISPLAY, etc templates and pasted it into a new added template called navbar_forums. I then referenced $navbar_forums in the aforementioned default templates and used your plugin code to get it to show up.

However, not all the cut and pasted code evaluates correctly through the $ reference, but if I remove the $ reference and paste the same code chunk directly back into SHOWTHREAD, it all works correctly.

The problem seems to be that this <if> statement does not evaluate properly regardless of whether I use a browser with or without popups (I test in multiple browsers)
<if condition="$show['popups']">
All the proper end tags and format is included. Dreamweaver thinks so too. So I thought perhaps it was an issue with $show, yet these other <if> statements in the same code chunk evaluate properly when I'm logged in or out
<if condition="$show['member']">
<if condition="$show['quicksearch']">


So how does a code chunk parse correctly, except when included through a new added template? Could this issue have something to do with the plugin code? Any other ideas?

davidw
07-25-2007, 12:51 PM
It could possibly - I've had two hacks that both use global_start conflict with each other, depending on its contents. To test this out, if sort your plugins by hook location and find others that share global_start. Then try disabling others one at a time to see if there is a conflict.

Also, although Dreamweaver may be satisfied that all tags have ends, your total script may not start/end. When a page is displayed, it displays everything in that page inclusive of all templates. If one previous template has an unclosed tag, or one latter template does not close, then you might have issues. The same goes with the basics of html. What you see in Dreamweaver is only one section of code, which satisfies by closing all tags, as you state. That is just something to keep in mind. (I've run into this upon occasion when building non-vbulletin websites completely from scratch)

Also, keep in mind, that although the code may satisfy tag closure, the code itself may have an issue within itself or with something else it is being used with.

If you want, PM me the code or paste it here and I will try to look at it later.

funrun
07-26-2007, 02:23 AM
No other plugins are using global_start, but my Downloads plugin was using cache_templates. I disabled that one, emptied my browser cache, but it made no difference.

I understand the idea that another template may not open or close properly, but in my tests I replace the template "$reference" with all of the code from the actual referenced template. In theory the same code gets exported in the end, so any improperly opened or closed tags in the rest of the page should have the same affects, no?

I feel like I can't explain without a short, fake example (because my actual code is very long):

If SHOWTHREADS contains:
<p>Unclosed p tag here
$navbar_forums
<p>hello world</p>
where the template "navbar_forums" contains this code:
<p>this is the new template</p>
Then the combined codes above ultimate displays in the browser such as:
Unclosed p tag here

this is the new template

hello world

Or

If I just wrote SHOWTHREADS as:
<p>Unclosed p tag here
<p>this is the new template</p>
<p>hello world</p>
It should still output exactly the same way in the browser, correct?

davidw
07-26-2007, 02:29 AM
Are you calling another template within the custom template? If so, that will most likely not work (I've spent a couple hours working on an 7-day ad rotation hack that had similar issues).

M.C.
12-17-2010, 09:34 PM
You'll need to do these things:
1) Create your template, templatename, which you've already done and
2) Create 2 plugins
Go to your admincp => Plugins & Products => Add New Plugin =>

Plugin 1
Product - vbulletin
Hook Location - cache_templates
Title - Title of Plugin 1
Plugin PHP Code - $globaltemplates[] = 'templatename';

and

Plugin 2
Product - vbulletin
Hook Location - global_start
Title - Title of Plugin 2
Plugin PHP Code global $db, $vbulletin;
eval('$templatename .= "' . fetch_template('templatename') . '";');

tried to do it but with no luck :( my template not fetch in header... any suggestions?

BirdOPrey5
12-19-2010, 09:08 PM
tried to do it but with no luck :( my template not fetch in header... any suggestions?

You bumped a very old thread, are you using VB4? If so this won't work with VB4 so I suggest asking for help (or better yet searching) the 4.x forum.

If you do have 3.x are you getting any error at all? Are you double sure your plugins were set to ACTIVE (YES)?