View Full Version : Including one template in another
Cedric_FP
10-05-2009, 04:30 AM
Hello,
I have made a custom template and want to include it at the top of my header template for ease, so when I update the reverts don't remove my code.
If the custom template is called "HEADERLOGINBOX" how could I call it at the start of my standard header template?
I've tried $HEADERLOGINBOX but that doesn't work.
Thanks for your help.
ChopSuey
10-05-2009, 04:40 AM
Cant you just take the login box from the navbar template and use it in the header?
Cedric_FP
10-05-2009, 04:47 AM
Cant you just take the login box from the navbar template and use it in the header?
No. I need to do it this way because I have completely customized the header.
What i want to do is include my custom template inside the header so that when I update, the reverts don't mess everything up.
The login box in the navbar template actually has nothing to do with my custom header.
Lynne
10-05-2009, 05:09 PM
You need to eval your template in a plugin so the variable is available for use.
eval('$yourvariable .= " ' . fetch_template('your_template') . '";');
Cedric_FP
10-06-2009, 09:40 PM
Thanks Lynne. Will give that a shot tonight :)
Where would I hook it? Header_redirect?
ZeepySea
10-07-2009, 12:37 AM
Don't need to hook it, just call it where you want in the style.
As Lynne showed, replace $yourvariable with $headerloginbox calling the template you created in place of your_template. You'll need to add that eval to a page somewhere.
Then in the header template place the $headerloginbox where you would like.
Cedric_FP
10-07-2009, 10:35 AM
Don't need to hook it, just call it where you want in the style.
As Lynne showed, replace $yourvariable with $headerloginbox calling the template you created in place of your_template. You'll need to add that eval to a page somewhere.
Then in the header template place the $headerloginbox where you would like.
I'm sorry but I don't understand what you mean by adding the eval to a page?
Lynne
10-07-2009, 02:31 PM
It sounds to me like the OP does need to use a plugin since this is not on a custom page, but on every page. And, since you want it included in the header, you'll have to use a very early hook location like a global_* one (global_start?). So, try that.
squishi
10-07-2009, 07:51 PM
The way to do this is to look at what php page you are loading.
So it depends where you want to insert the template.
Let's say you want to insert a template on a thread's page somewhere in the SHOWTHREAD template.
So you would be looking at the thread with the showthread.php file.
This is the file that you have to scan for hooks.
Open it in a text editor and check what hooks are in the php file and where they are located.
Often, there is a hook at the end which is safe to hook into (in this case 'showthread_complete').
Then you do as suggested above. Go to the plugins. Create a plugin for the hook you just found. Eval the template in that hook and use the variable in the showthread template.
Cedric_FP
10-08-2009, 01:18 AM
It sounds to me like the OP does need to use a plugin since this is not on a custom page, but on every page. And, since you want it included in the header, you'll have to use a very early hook location like a global_* one (global_start?). So, try that.
I see. I'll give that a shot as I do want it in the header, and therefore to appear on every page.
The way to do this is to look at what php page you are loading.
So it depends where you want to insert the template.
Let's say you want to insert a template on a thread's page somewhere in the SHOWTHREAD template.
So you would be looking at the thread with the showthread.php file.
This is the file that you have to scan for hooks.
Open it in a text editor and check what hooks are in the php file and where they are located.
Often, there is a hook at the end which is safe to hook into (in this case 'showthread_complete').
Then you do as suggested above. Go to the plugins. Create a plugin for the hook you just found. Eval the template in that hook and use the variable in the showthread template.
Thanks for the input! So this method would remain roughly the same for, say, forumhome.php?
Thanks people :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.