MyBB Community Forums

Full Version: How to create a multiple global templates?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I want that my plugin create two or more global templates but I don't know how to do it! The code for make a template is the following:


function plugin_activate() {
global $mybb, $db;

$templatearray = array(
"tid" => "NULL",
"title" => 'template_name',
"template" => $db->escape_string('
<p>hello</p>'),
"sid" => "-1",
);

$db->insert_query("templates", $templatearray);

//other plugin code

}

But what if I want to make two or more templates?

P.S. I don't understand very well what is "sid", could anyone explain me what is that?
http://docs.mybb.com/1.8/development/plu...e-methods/#$db->insert_query_multiple

$insert = array(array(
    "title"    => 'template_name',
    "template" => $db->escape_string('<p>hello</p>'),
    "sid"      => "-1",
    "dateline" => TIME_NOW
), array(
    "title"    => 'template_name_2',
    "template" => $db->escape_string('<p>hello 2</p>'),
    "sid"      => "-1",
    "dateline" => TIME_NOW
));

$db->insert_query_multiple('templates', $insert);

Template Set ID.
-1 is global.
Anything higher is an actual themes templates.

Basically just go to the template sector of the admin panel and hover the templates you'll see they all have set sid's.