MyBB Community Forums

Full Version: Did something with templates. Need some assistance
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I was editing showthread_newthread template, and when I was done in the “Template Name” box I typed “showthread” (I thought this would lead me to the template) and it seems to have broke my showthread.php (whenever I try to open a thread, it’ll just show a “Post Thread” link and that’s it)

The page source is also the showthread_newthread template, but in my showthread template everything seems to be normal. 

What should I do next to getting my showthread pages to be normal? Thanks!
(2019-12-18, 05:58 PM)makpaolo Wrote: [ -> ](...) and when I was done in the “Template Name” box I typed “showthread” (I thought this would lead me to the template) and (...)

By doing so, you're just submitting current content in the input textbox to the showthread template upon clicking either save button. That's indeed confusing and MyBB should make this "Template Name" input field disabled for editing.

(2019-12-18, 05:58 PM)makpaolo Wrote: [ -> ]What should I do next to getting my showthread pages to be normal? Thanks!

The former content of your showthread template is overwritten with the content you've submitted, so basically there might be no way for you to find it back from your current database.

If you haven't made any modification to the showthread template before this "edit by mistake", copy the content of this specific template from your theme installation file. Either a published theme or MyBB's default theme has a xml file for installation.

Or if you have a database backup before this "edit by mistake", you could recover this template's contents from that backup.

Otherwise, there's no more direct way for recovery, and maybe you could copy the content of this template from MyBB default theme then modify and adapt it to your existing theme/template.
(2019-12-18, 06:29 PM)noyle Wrote: [ -> ]If you haven't made any modification to the showthread template before this "edit by mistake", copy the content of this specific template from your theme installation file. Either a published theme or MyBB's default theme has a xml file for installation.

I'm a little confused what you mean by this.
There was modification to the showthread template, but I still have the XML file for the theme (there weren't too many edits specifically with showthread template, but CSS wise there has been a lot of editing)

My showthread template still has the original content, but it seems like the showthread_newthread takes control over that template or something.
(2019-12-18, 06:45 PM)makpaolo Wrote: [ -> ]
(2019-12-18, 06:29 PM)noyle Wrote: [ -> ]If you haven't made any modification to the showthread template before this "edit by mistake", copy the content of this specific template from your theme installation file. Either a published theme or MyBB's default theme has a xml file for installation.

I'm a little confused what you mean by this.
There was modification to the showthread template, but I still have the XML file for the theme (there weren't too many edits specifically with showthread template, but CSS wise there has been a lot of editing)

My showthread template still has the original content, but it seems like the showthread_newthread takes control over that template or something.

Huh I've no idea why the actual page is wrong if the showthread template is still having the original content.

If I understand you correctly, the content of the showthread template should be the same as showthread_newthread's, either from AdminCP's template editing or from the forum's front-end. If this is the case, open that xml file, search for <template name="showthread", copy the content between <template name="showthread" version="18xx"><![CDATA[ and ]]></template> (don't cross other following templates) and replace the wrong content in current showthread template and save.
(2019-12-18, 07:19 PM)noyle Wrote: [ -> ]
(2019-12-18, 06:45 PM)makpaolo Wrote: [ -> ]
(2019-12-18, 06:29 PM)noyle Wrote: [ -> ]If you haven't made any modification to the showthread template before this "edit by mistake", copy the content of this specific template from your theme installation file. Either a published theme or MyBB's default theme has a xml file for installation.

I'm a little confused what you mean by this.
There was modification to the showthread template, but I still have the XML file for the theme (there weren't too many edits specifically with showthread template, but CSS wise there has been a lot of editing)

My showthread template still has the original content, but it seems like the showthread_newthread takes control over that template or something.

Huh I've no idea why the actual page is wrong if the showthread template is still having the original content.

If I understand you correctly, the content of the showthread template should be the same as showthread_newthread's, either from AdminCP's template editing or from the forum's front-end. If this is the case, open that xml file, search for <template name="showthread", copy the content between <template name="showthread" version="18xx"><![CDATA[ and ]]></template> (don't cross other following templates) and replace the wrong content in current showthread template and save.

The showthread template in the Admin CP is the correct showthread code. It does not contain the showthread_newthread contents at all, but when you open a thread link, in the page source it will show the showthread_newthread contents. Very weird.

My showthread in the Admin CP right now is:
<html>
<head>
<title>{$thread['subject']}</title>
{$headerinclude}
<script type="text/javascript">
<!--
	var quickdelete_confirm = "{$lang->quickdelete_confirm}";
	var quickrestore_confirm = "{$lang->quickrestore_confirm}";
	var allowEditReason = "{$mybb->settings['alloweditreason']}";
	lang.save_changes = "{$lang->save_changes}";
	lang.cancel_edit = "{$lang->cancel_edit}";
	lang.quick_edit_update_error = "{$lang->quick_edit_update_error}";
	lang.quick_reply_post_error = "{$lang->quick_reply_post_error}";
	lang.quick_delete_error = "{$lang->quick_delete_error}";
	lang.quick_delete_success = "{$lang->quick_delete_success}";
	lang.quick_delete_thread_success = "{$lang->quick_delete_thread_success}";
	lang.quick_restore_error = "{$lang->quick_restore_error}";
	lang.quick_restore_success = "{$lang->quick_restore_success}";
	lang.editreason = "{$lang->postbit_editreason}";
	lang.post_deleted_error = "{$lang->post_deleted_error}";
	lang.softdelete_thread = "{$lang->soft_delete_thread}";
	lang.restore_thread = "{$lang->restore_thread}";
// -->
</script>
<!-- jeditable (jquery) -->
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/report.js?ver=1820"></script>
<script src="{$mybb->asset_url}/jscripts/jeditable/jeditable.min.js"></script>
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/thread.js?ver=1820"></script>
</head>
<body class="showthread">
	{$header}
	
	<div class="boxed page_header">
		<div class="page_head">
			<div class="page_head_title"><h1>{$thread['subject']}</h1></div>
			<div class="page_head_desc"></div>
		</div>
	</div>
	{$threadnotesbox}
	{$pollbox}
	
	<div class="boxed">
		<div class="page_thead"><h2>Topic Title : {$thread['threadprefix']}{$thread['subject']}</h2></div>					
		<div class="page_headers">
			<div class="page_header_icon">
				<img src="{$theme['imgdir']}/showthread.png" alt="*">
			</div>
			<div>
				<div class="page_header_title">
					<div class="page_header_desc">
					<i class="fas fa-circle"></i> This topic has been commented on {$thread['replies']} times.<br>
					<i class="fas fa-circle"></i> Owner : {$thread['username']}
				</div>
			</div>
		</div>
		<div class="page_header_buttons">
			{$ratethread}
			{$printthread}
			{$sendthread}
			{$addremovesubscription}
			{$addpoll}
			{$newreply}
		</div>
	</div>
	</div>
	<div class="mobile_float float_left" style="padding-bottom: 4px;">
		{$newthread}
	</div>
	<div class="mobile_float float_right">
		{$multipage}
	</div>
	
	
	<div id="posts">
		{$first_post}{$posts}
	</div>
	
	<div style="padding-top: 4px;" class="float_left">
		{$multipage}
	</div>
		
	<div class="mobile_float float_right">
		{$newthread}
	</div>
		
	<br class="clear" />
	{$quickreply}
	{$threadexbox}
	{$similarthreads}
	<br />
	

	<div class="mobile_float float_right" style="text-align: right;">
		{$moderationoptions}
		{$forumjump}
	</div>
		
	<br class="clear" />
	{$usersbrowsing}
	{$footer}
		
	<div id="thread_modes_popup" class="popup_menu" style="display: none;"><div class="popup_item_container"><a href="showthread.php?mode=linear&amp;tid={$tid}&amp;pid={$pid}#pid{$pid}" class="popup_item">{$lang->linear}</a></div><div class="popup_item_container"><a href="showthread.php?mode=threaded&amp;tid={$tid}&amp;pid={$pid}#pid{$pid}" class="popup_item">{$lang->threaded}</a></div></div>
	<script type="text/javascript">
	// <!--
		if(use_xmlhttprequest == "1")
		{
			$("#thread_modes").popupMenu();
		}
	// -->
	</script>
	<script type="text/javascript">
		var thread_deleted = "{$thread_deleted}";
		if(thread_deleted == "1")
		{
			$("#quick_reply_form, .new_reply_button, .thread_tools, .inline_rating").hide();
			$("#moderator_options_selector option.option_mirage").attr("disabled","disabled");
		}
	</script>
</body>
</html>

However, the source of any thread link will show (this is my showthread_newthread template pretty much):
<script src="https://mywebsite.com/jscripts/obfuscated.js"></script><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<a href="newthread.php?fid=38" class="btn button26 new_thread_button"><span>Post Thread</span></a>&nbsp;
That's pretty weird. I can't reproduce that with the vanilla MyBB AdminCP template editing module. Did you use template editing plugins? Maybe you need someone to have a look.

OK, there's only a few random guess I can make:
Try to rebuild & reload MyBB's cache.
Try to save the showthread template again with current content.
Try to modify the showthread template and then use the "revert" template function on this template.
(2019-12-18, 07:42 PM)noyle Wrote: [ -> ]That's pretty weird. I can't reproduce that with the vanilla MyBB AdminCP template editing module. Did you use template editing plugins? Maybe you need someone to have a look.

OK, there's only a few random guess I can make:
Try to rebuild & reload MyBB's cache.
Try to save the showthread template again with current content.
Try to modify the showthread template and then use the "revert" template function on this template.

That seemed to have done the trick.

What I did was revert it to the original template, which actually converted to what was showing in the page source. I then pasted the contents of showthread and it worked. I tried doing all of this without reverting to default and it did not work, so it seems like reverting did the trick.

Thank you noyle