vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Custom Template? (https://vborg.vbsupport.ru/showthread.php?t=207382)

Chadi 03-04-2009 11:13 PM

Custom Template?
 
I'd like to create a new custom template like I have done in the past. I usually name them like this:

custom_SomeName

I'd like to add some small html content (div/tables) into that custom template and be able to pull that template into another template like this:

$customtemplatename

I tried this but it did not work at all. Would appreciate help on this.

Lynne 03-05-2009 03:19 AM

You need to eval the template like this in order to then use the contents as a variable:
eval('$customtemplatename .= "' . fetch_template('custom_SomeName') . '";');

Now, you may use $customtemplatename in a template that you eval after that one in the file.

Chadi 03-05-2009 03:22 AM

Where would that eval code go? What file?

Lynne 03-05-2009 03:44 AM

Wherever you are needing to use the template.

Chadi 03-05-2009 04:02 AM

I don't understand sorry.

For example:

I have some basic html code (for a css menu) in a custom template called "cssmenu" let's say.

Then, I want to use $cssmenu in navbar and footer for example. I have to place the below code in those two templates?

Code:

eval('$cssmenu .= "' . fetch_template('cssmenu') . '";');

Lynne 03-05-2009 04:15 AM

No, php cannot go in into a template. You need to paste that php code into a php file or into a plugin that is called *before* the templates you want to use it in. So, in this case, you need to put that code either directly into a php file, or use a plugin that is evaled before the navbar and footer get evaled (one of the global hook locations?). I think you may also need to add that template to the $globalarray template (another plugin or code edit needed).

Dismounted 03-05-2009 04:34 AM

Quote:

Originally Posted by Lynne (Post 1760764)
I think you may also need to add that template to the $globalarray template (another plugin or code edit needed).

$globaltemplates ;) Add your template to that array so it gets cached before use.

Lynne 03-05-2009 03:02 PM

Quote:

Originally Posted by Dismounted (Post 1760782)
$globaltemplates ;) Add your template to that array so it gets cached before use.

*I* knew what I meant! (It's a good thing you come around after my evening posts!)

Chadi 03-05-2009 10:06 PM

Quote:

Originally Posted by Dismounted (Post 1760782)
$globaltemplates ;) Add your template to that array so it gets cached before use.

Sorry, still not comprehending this at all.

I searched all templates for "globaltemplates", nothing found.

I went to plug-in manager, clicked add and have this active:

https://vborg.vbsupport.ru/external/2009/03/51.png

I did nothing else, aside adding my basic html content inside a custom template called custom_Media.

I'm not sure what to do from here now. I'm not even sure the above plugin is correct.

Lynne 03-06-2009 01:06 AM

$globaltemplates is not a template - it's a variable. This may help you to see how things work regarding the use of a template in code - [How-To] vBulletin API Basics: Creating Custom Pages & Misc. Notice the template has to be included in the $globabltemplates array at the top, the code gets done, then the template gets evaled. It *must* be in that order.


All times are GMT. The time now is 10:51 PM.

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.01866 seconds
  • Memory Usage 1,731KB
  • 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_code_printable
  • (3)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