vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Including one template in another (https://vborg.vbsupport.ru/showthread.php?t=224590)

Cedric_FP 10-05-2009 03:30 AM

Including one template in another
 
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 03:40 AM

Cant you just take the login box from the navbar template and use it in the header?

Cedric_FP 10-05-2009 03:47 AM

Quote:

Originally Posted by ChopSuey (Post 1894997)
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 04:09 PM

You need to eval your template in a plugin so the variable is available for use.

PHP Code:

eval('$yourvariable .= " ' fetch_template('your_template') . '";'); 


Cedric_FP 10-06-2009 08:40 PM

Thanks Lynne. Will give that a shot tonight :)

Where would I hook it? Header_redirect?

ZeepySea 10-06-2009 11:37 PM

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 09:35 AM

Quote:

Originally Posted by ZeepySea (Post 1895911)
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 01: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 06: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 12:18 AM

Quote:

Originally Posted by Lynne (Post 1896144)
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.

Quote:

Originally Posted by squishi (Post 1896282)
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 :)


All times are GMT. The time now is 03:08 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01959 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete