Edit template (plugin)
From Game Section
NOTE THAT THIS PAGE IS ABOUT GAME SECTION 1.1.x
NOTE THAT THIS IS INCLUDED IN GAME SECTION 1.2.x BY DEFAULT
There is no function to find and replace parts of a template of the Game Section. When you want to edit a template in your plugin, you can do that by including this function into your plugin.
The function
// Function to replace strings in templates
function replace_templates_gs($title, $find, $replace, $themes=1)
{
global $db;
//Themes
if($themes == 0)
{
$where_theme = " AND theme='1'";
}
//Load current template
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."games_templates WHERE title='".$title."'".$where_theme);
while($template = $db->fetch_array($query))
{
$old_template = addslashes($template['template']);
$new_template['template'] = addslashes(preg_replace($find, $replace, $template['template']));
$new_template['dateline'] = time();
if($template['template'] != $old_template)
{
$db->update_query(TABLE_PREFIX."games_templates", $new_template, "tid='".$template['tid']."'");
}
}
}
Documentation
- title: The name/title of the template
- find: An array with all patterns
- replace: An array with all replacements
- themes: Here, you can choose between all themes (1) and the default Game Section theme (0)
In Practice
To see an example in practice, you can download the report system. This uses this function.

