2012-08-01, 12:09 AM
2012-08-01, 12:22 AM
// Insert Templates
require MYBB_ROOT."/inc/adminfunctions_templates.php";
$template = array(
"title" => "TEMPLATE_NAME",
"template" => 'TEMPLATE COPE GOES HERE',
"sid" => -1
);
$db->insert_query("templates", $template);
2012-08-01, 07:25 AM
Thanks a lot. How to remove it again when uninstalling?
2012-08-01, 10:37 AM
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='TEMPLATE_NAME'");
2012-08-01, 12:17 PM
You don't need to require ./inc/adminfunctions_templates.php to do any of this. That file only contains the find_replace_templatesets() function and clearly that isn't needed here. It's completely unnecessary.
You will, however, need to put $db in the global scope to be able to do this. And although the $db->query method can be used to delete things from the database, $db->delete_query should always be preferred.
You will, however, need to put $db in the global scope to be able to do this. And although the $db->query method can be used to delete things from the database, $db->delete_query should always be preferred.