MyBB Community Forums

Full Version: PluginLibrary add a global template
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Heya, I need some assistance.

Whilst working on my plugin, I am needing (wanting) to add a global template.

I am using Plugin Library for my plugin and my code is:

$PL->templates("steam-mod", "Steam Mod Templates", array(""=>"blabla"));

Any clue how to make this go into global templates instead of default theme templates?

Thanks in advance!
Sorry, not possible; if your templates must be global, you'd have to add them to the database the old fashioned way (or create manually in the Admin CP, which you can always do without the support of a plugin).

The templates() function can only create master templates, i.e. the ones that can be customized for each theme/template set. So it's the more powerful solution. Those are also the only ones that can be updated, or version tracked, so the $PL->templates() functionality (such as keeping user edits on plugin updates and find such templates using the "find updated templates" function) are not possible with global templates.
Ah okay, thank you Frost. Could you assist me in creating it without PL?
$my_template = array(
			       "title" => 'my_unique_template_name',
			       "template" => $db->escape_string('your HTML code <b>here</b>'),
			       "sid" => -1,
			       "version"	=> "1610",
			       "dateline"	=> TIME_NOW,
			       );
$db->insert_query('templates', $my_template);
Add something similar to install or activate function.

$db->delete_query('templates', "title = 'my_unique_template_name'");
Add something similar to uninstall or deactivate function.
Ah, I see. Thank you much. Smile