MyBB Community Forums

Full Version: Update and Reload Template MOD! (Admin CP Modification)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Screenshot:
[Image: vbuar3nk.th.jpg]

This mod will replace your "Update Template" button with an "Update and Reload" button. This will template editing easier for designers like me Smile
This mod will also add an "Exit Template" so that you will not go through the hasstle of moving your mouse to the sidebar Toungue hehe

Though this is an easy mod to apply...
PLEASE BACKUP THE RELATED FILES BEFORE EDITING!
Files affected:
languages/english/admin/templates.lang.php
admin/adminfunctions.php
admin/templates.php


Difficulty: Very Easy
Made for MyBB RC4
--------------------------------------------------------------------------
Update and Reload Tamplate MOD

Edit languages/english/admin/templates.lang.php
----------------------------------------------------
Find:
$l['update_template'] = "Update Template";
Replace with:
$l['update_template'] = "Update and Reload Template";
//START U&R Template
$l['exit_template'] = "Exit Template";
//End U&R Template
----------------------------------------------------
Save and upload languages/english/admin/templates.lang.php
----------------------------------------------------


Edit admin/adminfunctions.php
----------------------------------------------------
Find:
function endform($submit="", $reset="")
{
	if($submit || $reset)
	{
		echo "<div align=\"center\"><div class=\"formbuttons\">\n";
	}
	if($submit)
	{
		echo makebuttoncode($submit, $submit, "submit");
	}
	if($reset)
	{
		echo makebuttoncode($reset, $reset, "reset");
	}
	if($submit || $reset)
	{
		echo "</div></div>";
	}
	echo "</form>\n";
}
Add after:
//START U&R Template
function exit_template($setid,$value)
{
	echo "<div align='center'><input type='submit' value='$value' onclick=\"hopto('templates.php?expand=$setid');\"></div>";
}
//END U&R Template
----------------------------------------------------
Save and upload admin/adminfunctions.php
----------------------------------------------------

Edit admin/templates.php
----------------------------------------------------
Find:
if($action == "do_edit") {
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."templates WHERE tid='$tid'");
	$templateinfo = $db->fetch_array($query);

	if($title == "") {
		$title = $templateinfo[title];
	}
	$template = addslashes($template);
	$db->query("UPDATE ".TABLE_PREFIX."templates SET template='$template', title='$title', sid='$setid' WHERE tid='$tid'");
	cpredirect("templates.php?expand=$setid", $lang->template_edited);
}
Replace with:

//START U&R Template
if($action == "do_edit") {
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."templates WHERE tid='$tid'");
	$templateinfo = $db->fetch_array($query);

	if($title == "") {
		$title = $templateinfo[title];
	}
	$template = addslashes($template);
	$db->query("UPDATE ".TABLE_PREFIX."templates SET template='$template', title='$title', sid='$setid' WHERE tid='$tid'");
	cpredirect("templates.php?action=edit&tid=$tid", $lang->template_edited);
}
//END U&R Template

Find:
if($action == "edit") {
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."templates WHERE tid='$tid'");
	$template = $db->fetch_array($query);
	$template[template] = stripslashes($template[template]);
	$template[template] = stripslashes($template[template]);

	cpheader();
	if($template[sid] != "-2") {
		startform("templates.php", "" , "do_edit");
		makehiddencode("tid", $tid);
		starttable();
		tableheader($lang->modify_template);
		makeinputcode($lang->title, "title", $template[title]);
	} elseif(md5($debugmode) == "0100e895f975e14f4193538dac4d0dc7" && $template[sid] == -2) {
		startform("templates.php", "" , "do_edit");
		makehiddencode("tid", $tid);
		starttable();
		tableheader($lang->modify_master_template);
		makeinputcode($lang->title, "title", $template[title]);
	} else {
		starttable();
		tableheader($lang->view_template);
		makelabelcode($lang->title, $template[title]);
	}
	maketextareacode($lang->template, "template", "$template[template]", "25", "80");
	if($template[sid] != "-2") {
		makeselectcode($lang->template_set, "setid", "templatesets", "sid", "title", "$template[sid]", "Global - All Template Sets");
	} else {
		makehiddencode("setid", $template[sid]);
	}
	endtable();
	if(($template[sid] != -2) || (md5($debugmode) == "0100e895f975e14f4193538dac4d0dc7" && $template[sid] == -2)) {
		endform($lang->update_template, $lang->reset_button);
	}
	cpfooter();
}
Replace with:
//START U&R Template
if($action == "edit") {
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."templates WHERE tid='$tid'");
	$template = $db->fetch_array($query);
	$template[template] = stripslashes($template[template]);
	$template[template] = stripslashes($template[template]);

	cpheader();
	if($template[sid] != "-2") {
		startform("templates.php", "" , "do_edit");
		makehiddencode("tid", $tid);
		starttable();
		tableheader($lang->modify_template);
		makeinputcode($lang->title, "title", $template[title]);
	} elseif(md5($debugmode) == "0100e895f975e14f4193538dac4d0dc7" && $template[sid] == -2) {
		startform("templates.php", "" , "do_edit");
		makehiddencode("tid", $tid);
		starttable();
		tableheader($lang->modify_master_template);
		makeinputcode($lang->title, "title", $template[title]);
	} else {
		starttable();
		tableheader($lang->view_template);
		makelabelcode($lang->title, $template[title]);
	}
	maketextareacode($lang->template, "template", "$template[template]", "25", "80");
	if($template[sid] != "-2") {
		makeselectcode($lang->template_set, "setid", "templatesets", "sid", "title", "$template[sid]", "Global - All Template Sets");
	} else {
		makehiddencode("setid", $template[sid]);
	}
	endtable();
	if(($template[sid] != -2) || (md5($debugmode) == "0100e895f975e14f4193538dac4d0dc7" && $template[sid] == -2)) {
		endform($lang->update_template, $lang->reset_button);
	}
	exit_template($template[sid],$lang->exit_template);
	cpfooter();
}
//END U&R Template
----------------------------------------------------
Save and upload admin/templates.php
----------------------------------------------------
Very nice, hope you will do it for gold, too Smile