Skip to main content
Topic: How to add a new template (Read 2448 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to add a new template

Suppose as a part of the theme, you create a new template. How will you add it and make the functions inside it valid ? When I created one and placed among other templates, ElkArte refused to recognize functions defined in it.

Re: How to add a new template

Reply #1

So you are talking about files named something.template.php, correct?
In that case, unfortunately, at the moment ElkArte doesn't know how to load these files automatically, so if you want to use any you have to load the files manually.
I would suggest something like that:
Code: [Select]
loadTemplate('TemplateName');
it's not the best place, but considering your approach, the best place for that function would be inside template_init.

Though, @Spuds this may be something to consider for themes extensibility (i.e. allow theme to load their preferred templates.
Thinking out loud: it may lead to some inconsistencies, though it should be fine. The best way would be to "finish" the template call branch from Josh and then have an autoloader for the template classes as well.
Food for thoughts.
Bugs creator.
Features destroyer.
Template killer.

Re: How to add a new template

Reply #2

Thanks @emanuele . How about adding a sub template to a template ? I saw that Admin template has one by the name theme options. May be more.

Re: How to add a new template

Reply #3

There isn't any technical difference between templates and sub-templates (even though "sub template" is a tricky word because it may mean two different things, I feel you are referring to callbacks, but I'm not entirely sure): both are functions that can be called at some point, make sure the file is loaded and you can use them. If I got the question right. ;)
Bugs creator.
Features destroyer.
Template killer.