MyBB Documentation

Changing Templates

The 1.6 Documentation is no longer maintained and some information may be outdated.

The MyBB 1.6 series reached end of life on October 1, 2015.

This means there will be no more security or maintenance releases for these series and forums running these versions of MyBB may be at risk of unfixed security issues. All administrators are strongly encouraged to upgrade their forums to the latest release of MyBB as soon as possible.

On this page, you will find how to make template edits in plugins.

Here is how to make a basic template edit. For this example, we are going to edit the index template and add the variable {$randomvar} after the board statistics.

function pluginname_activate()
{
global $db;
	require MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets(
		"index",
		'#'.preg_quote('{$boardstats}').'#',
		'{$boardstats}{$randomvar}'
	);
}

To reverse the template edit do this:

function pluginname_deactivate()
{
global $db;
	require MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets(
		"index",
		'#'.preg_quote('{$randomvar}').'#',
		''
	);
}

Edit this page on GitHub