PDA

View Full Version : Custom Template?


Chadi
03-04-2009, 11:13 PM
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?

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
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
$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
$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. (https://vborg.vbsupport.ru/showthread.php?t=98009) 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.