vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Design and Graphics Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=168)
-   -   Call a template in another template! (https://vborg.vbsupport.ru/showthread.php?t=140502)

Mr Pink 02-26-2007 10:42 AM

Call a template in another template!
 
Hi, I've a template called "mytemplatetest", and I want call it in another template, if possible. I've try with $mytemplatetest (viewing the called $footer, $header, etc., templates), but it doesn't work.
Can you please help me?



Best regards,
Mr Pink (aka Norman)
Web City Forum Online
http://www.web-city.it/

CyberAlien 02-26-2007 11:10 AM

You can't include other template files in a template file, you need to parse it separately in php code.

If you want to include that template on every page, then open global.php, find this:
Code:

$globaltemplates = array_merge($globaltemplates, array(
        // the really important ones
        'header',
        'footer',
        'headinclude',

and add your template name to that array

Then find this:
Code:

// parse some global templates
eval('$gobutton = "' . fetch_template('gobutton') . '";');
eval('$spacer_open = "' . fetch_template('spacer_open') . '";');
eval('$spacer_close = "' . fetch_template('spacer_close') . '";');

and add after it:
Code:

eval('$mytemplatetest = "' . fetch_template('mytemplatetest') . '";');
Then you can use $mytemplatetest in all templates.

Or write a hack that uses "parse_templates" hook to parse your template.

Mr Pink 02-26-2007 11:23 AM

Thanks really for your reply, CyberAlien.
So I need to put the entire code into the navbar template (I'm making a style, and I don't want use external files/modifications). :(

CyberAlien 02-26-2007 12:23 PM

There is another solution: replacements. Create replacement like "<my-header>", put your code in it, then use <my-header> in navbar template. < and > in replacement name are there to make sure there isn't any similar text within posts so nothing else will be replaced.

Mr Pink 02-26-2007 12:33 PM

The problem is that I'm trying to do a vB style that I'll posting here like a simple release (I'm doing it for learn coding and take familiarity with vB), so I can't use other resources rather then the simple template modification.

CyberAlien 02-26-2007 12:37 PM

Replacements are simple template modifications that you can safely use.

Mr Pink 02-26-2007 12:42 PM

If a user will download the style, then he will need to add the replacement, right?

CyberAlien 02-26-2007 12:46 PM

No, it will be in xml file.

Mr Pink 02-26-2007 12:51 PM

Oh, so I can use them. Great! I thought that users had to add them by themselves! Ok ok, great! Thanks again man. Now my problem is that in the other thread in this forum! :)


All times are GMT. The time now is 07:41 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.01060 seconds
  • Memory Usage 1,725KB
  • 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
  • (3)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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