[Tutorial] Making the 'Rules' page to show with rules.
#2
Um, I wouldn't suggest doing this as it currently is. What if people currently use this rules page?? You're removing current functionality, and removing a plugin hook, what it people use it??

What you should do is this... because of...

if($mybb->input['fid'])

... it executes that big block of code you're saying to remove, if there's an fid... what you should do, is after it says...

output_page($rules);
    }

... in the first code block, add...

   else
    {
        //code
    }

... where //code is the code you added into the elseif statement. Then, create a custom template, and change the eval code to eval that new template instead. Basically change the first bit of code you posted to this:

elseif($mybb->input['action'] == "rules")
{
	if($mybb->input['fid'])
	{
		$plugins->run_hooks("misc_rules_start");

		$query = $db->simple_select("forums", "*", "fid='".intval($mybb->input['fid'])."' AND active!=0");
		$forum = $db->fetch_array($query);

		$forumpermissions = forum_permissions($forum['fid']);

		if($forum['type'] != "f" || $forum['rules'] == '')
		{
			error($lang->error_invalidforum);
		}
		if($forumpermissions['canview'] != 1)
		{
			error_no_permission();
		}
		if(!$forum['rulestitle'])
		{
			$forum['rulestitle'] = $lang->sprintf($lang->forum_rules, $forum['name']);
		}

		require_once MYBB_ROOT."inc/class_parser.php";
		$parser = new postParser();
		$parser_options = array(
			"allow_html" => 1,
			"allow_mycode" => 1,
			"allow_smilies" => 1,
			"allow_imgcode" => 1,
			"filter_badwords" => 1
		);

		$forum['rules'] = $parser->parse_message($forum['rules'], $parser_options);

		// Make navigation
		build_forum_breadcrumb($mybb->input['fid']);
		add_breadcrumb($forum['rulestitle']);

		$plugins->run_hooks("misc_rules_end");

		eval("\$rules = \"".$templates->get("misc_rules_forum")."\";");
		output_page($rules);
	}
	else
	{
		add_breadcrumb("Rules Page", "misc.php?action=rules");
		eval("\$rules = \"".$templates->get("TEMPLATE")."\";");
		output_page($rules);
	}

}

Change TEMPLATE to the name of the template you create. Then, if there's an fid, it'll work as normal, and if there isn't, it'll show the new page you're adding.

And sorry, I opened quick edit to copy your code whilst I had my quick edit open too, and I clicked save on yours by accident so it says I've edited yours, I didn't change anything, sorry!!
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
Reply


Messages In This Thread
RE: [Tutorial] Making the 'Rules' page to show with rules. - by Matt - 2009-09-26, 04:39 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)