MyBB Community Forums

Full Version: [Development] Understanding the template system
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I dont exactly understand how the single templates are interlocked.

For example there are the following templates:

index
index_boardstats

I guess that 'index_boardstats' is called inside 'index' via {$boardstats}, isn't it?

So I made an 'index_test' with content '<p>hello world</p>' and included it in the 'index'-template as {$test}. But this doesn't seem to work. How is this handled correctly? Couldn't find any wiki entry or any other information about this.

Help would be appreciated,


greez Lorus
It's true that index_boardstats is "called" within index. But the way of naming is actually to have some sort of grouping. It will not automatically detects the templates to include. You need to use a plugin or mod to assign the $test-variable in the index.php file. Although, if you would like to distribute the theme I wouldn't recommend that.

What exactly do you want to do?
I want a plugin to create a single template. Then I want to include this tempate into the index template. I think this is much cleaner then messing the index template with a bunch of code.
You can just add a code in template where you want to add it.. example in header just add the code
Hmm ok, but I want to add a bunch of lines ... so when there is a template system to keep things clean and structured , why not using it?
(2011-01-19, 11:46 AM)lorus Wrote: [ -> ]Hmm ok, but I want to add a bunch of lines ... so when there is a template system to keep things clean and structured , why not using it?

Ok got it with something like this:

$plugins->add_hook("index_start", "test_hook_index");

function test_hook_index() {

        global $templates, $index_test;

        eval("\$index_test = \"".$templates->get("index_test")."\";");

}

In my next step I want to automatically create the 'index_test' template by the plugin. Is there any function for this or have I do it by a db insert query?
db insert query.
Review some existing large plugins. You'll likely see good examples of functions to do a variety of things.