MyBB Community Forums

Full Version: [Tutorial] How to restore a deleted template, or 'blue name' template
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
This comes up occasionally, so I'll write this so people know how to fix it (and so I can quickly find it too Angel).

Sometimes, the master copy of a template can be deleted. The master template is basically the default template, what you compare to on a Diff Report, and what is reverted to when you revert an edited template to default. Sometimes, the template may just disappear from the list of template (as if it's unedited, the default will be being used, so if it's been deleted, it won't show up anywhere), and sometimes, you may see the name of the template in blue text, because the template is showing up as being a custom template, as it doesn't have a master.

Going to ACP > Templates & Style > Templates > Add Template > will not work because this will just add a new custom template, even if you use the same name as the affected default template. To fix this, you need to run this query:

INSERT INTO mybb_templates
(title,template,sid,version)
VALUES
('name',
'content',
'-2',
'1400');

You only need to change the name and content value. The name is simply the name of the affected template, and the content is, unsurprisingly, the template itself. You can get this from a test forum or localhost installation. Make sure it is actually the default template. It will just cause more issues in the long run if you put a modified template into this query. Also remember to escape ' and " in the template by changing them to \' and \"

Keep the -2 as it is, as it's a default MyBB template. It will usually be fine to keep the version as 1400, as we just need to get it added back into the database. However, you can find the appropriate version and use that if you want to.

Then, the template should be working as usual.

Finally, if anyone has any idea how they actually manage to do this, could you let me know. Sometimes it seems to happen when installing plugins, and there was a bug in versions up to and including 1.4.7 that made it possible to do this, but other than that, I'm not sure how people manage it; it would be great if we can figure out how it happens.
thanks sir for making this a tutorial.. this would be a good support for every mybb users! Big Grin

anyway can this be fix on new version of mybb soon?
As I said, we don't really know what causes it, which is why I'd like it if people can tell us if they figure it out.
Thanks for the tutorial Matt, I tried to make it, but I always get a SQL error. I really need to recover the template because it's the headerinclude Confused

I escaped every " and ', can you tell me if I'm doing something wrong?
INSERT INTO mybb_templates
(title,template,sid,version)
VALUES
('headerinclude',
'<link rel=\"alternate\" type=\"application/rss+xml\" title=\"{$lang->latest_threads} (RSS 2.0)\" href=\"{$mybb->settings[\'bburl\']}/syndication.php\" />
<link rel=\"alternate\" type=\"application/atom+xml\" title=\"{$lang->latest_threads} (Atom 1.0)\" href=\"{$mybb->settings[\'bburl\']}/syndication.php?type=atom1.0\" />
<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$charset}\" />
<meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\" />
<script type=\"text/javascript\" src=\"{$mybb->settings[\'bburl\']}/jscripts/prototype.js?ver=1400\"></script>
<script type=\"text/javascript\" src=\"{$mybb->settings[\'bburl\']}/jscripts/general.js?ver=1400\"></script>
<script type=\"text/javascript\" src=\"{$mybb->settings[\'bburl\']}/jscripts/popup_menu.js?ver=1400\"></script>
<!--<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js\"></script>
<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js\"></script>
<script type=\"text/javascript\" src=\"{$mybb->settings[\'bburl\']}/{$theme[\'imgdir\']}/main.js\"></script>-->
{$stylesheets}
<script type=\"text/javascript\">
<!--
	var cookieDomain = \"{$mybb->settings[\'cookiedomain\']}\";
	var cookiePath = \"{$mybb->settings[\'cookiepath\']}\";
	var cookiePrefix = \"{$mybb->settings[\'cookieprefix\']}\";
	var deleteevent_confirm = \"{$lang->deleteevent_confirm}\";
	var removeattach_confirm = \"{$lang->removeattach_confirm}\";
	var loading_text = \'{$lang->ajax_loading}\';
	var saving_changes = \'{$lang->saving_changes}\';
	var use_xmlhttprequest = \"{$mybb->settings[\'use_xmlhttprequest\']}\";
	var my_post_key = \"{$mybb->post_code}\";
	var imagepath = \"{$theme[\'imgdir\']}\";
// -->
</script>
{$newpmmsg}',
'-2',
'1400');
It worked for me Confused What's the error you get?? Are you sure it's actually been deleted??
It appears as a blue template in one of my themes, and is completely vanished from the rest of the themes.

I checked the DB with phpMyAdmin, and it seems to be that the title is actually there. Though, I have no idea on how to check the rest. Nor how to make it appear again on my AdminCP.
last time, when my template was screw, I installing new mybb, and copying all theme/template database from new forum to old forum which broken.
and start again from the scratch, by importing my custom theme.

nice tips Matt.
I'll bookmark and try later. Smile
So, do I re-run the install script over the same DB?

EDIT: I've made a fresh install of MyBB and just imported what I had as FBI suggested. Thanks all for the help.
Gosh, it happened again with the footer on another theme I was working on Confused I can't re-install my whole board everytime this happends... is there any way to re-create the template even if some part of it exists on the DB alreayd? Some sort of over-write?
I don't even know what causes this to happen in the first place, I have no idea why it's happening to you this often. Do you have CodePress active??

Are you sure it's definitely not in the database?? Remember there's now be two footers, the default one and the edited one, is the default one still there?? I can't remember anyone else saying it had gone blue with the default still intact...
Hi, I'm new to this, but I did have a part of theme template go blue. What I did was I edited my theme (afresh chocolate) to add some header links, then thought I would be smart and save as a default template set for other themes in the afresh series. The name of the template I saved as a default went blue. I tried copying back etc, and it went green again, but I could not get the template to appear as it should. For me its no big deal - it was just a theme template and easily fixed. Im not sure if its even relevant to this thread as I am a total noob. If it's not, sorry for wasting your time....
Pages: 1 2 3