I am not sure I can explain what I want but I will try my best!
Is it possible to create a template in Global templates and then links that template with something like this {$something} how to do it properly?
// Hook
$plugins->add_hook("index_start", "myplugin_run");
function myplugin_activate()
{
global $mybb, $db;
// Template DB entry structure array
$new_template = array(
"title" => "new_global",
"template" => "<div class=\"some_cssClass\">{$another_var}</div>",
"sid" => -1,
"dateline" => TIME_NOW
);
// Save created template into database
$db->insert_query("templates", $new_template);
include MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("index", "#".preg_quote("{\$header}")."#i", "{\$header}\r\n{\$some_var}"); // Example of placing variable in templates
}
function myplugin_deactivate()
{
global $mybb, $db;
include MYBB_ROOT."/inc/adminfunctions_templates.php";
// Remove variable from templates
find_replace_templatesets("index", "#".preg_quote("\r\n{\$some_var}")."#i", "", 0);
// Delete created global template
$db->delete_query("templates", "title = 'new_global'");
}
function myplugin_run()
{
// Remember to include usable variables
global $db, $mybb, $templates, $some_var, $another_var;
// Assign value of variable in new created global template
$another_var = "Hello MyBB";
// Evaluate created template in injected variable
eval("\$some_var = \"".$templates->get("new_global")."\";");
}
}
Great reply could please take look at my other question in plugins please?