MyBB Community Forums

Full Version: Adding Forum {rules} to showthread?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I found it neccesary to remind users of the forum rules for the forum they are in while viewing/posting a thread. Since {rules} only parses in the forum display templates by default how could I get it to parse in the show threads templates using any safe means? I do have the patches plugin installed to apply php patches. It's really powerful plugin but I'm not great with PHP. Please help. Thank you.
Anyone? I'm sure someone else has thought of this before?
This is what is used in forumdisply.php:
 325  // Do we have any forum rules to show for this forum?
 326  $forumrules = '';
 327  if($foruminfo['rulestype'] != 0 && $foruminfo['rules'])
 328  {
 329      if(!$foruminfo['rulestitle'])
 330      {
 331          $foruminfo['rulestitle'] = $lang->sprintf($lang->forum_rules, $foruminfo['name']);
 332      }
 333      
 334      $rules_parser = array(
 335          "allow_html" => 1,
 336          "allow_mycode" => 1,
 337          "allow_smilies" => 1,
 338          "allow_imgcode" => 1
 339      );
 340  
 341      $foruminfo['rules'] = $parser->parse_message($foruminfo['rules'], $rules_parser);
 342      if($foruminfo['rulestype'] == 1 || $foruminfo['rulestype'] == 3)
 343      {
 344          eval("\$rules = \"".$templates->get("forumdisplay_rules")."\";");
 345      }
 346      else if($foruminfo['rulestype'] == 2)
 347      {
 348          eval("\$rules = \"".$templates->get("forumdisplay_rules_link")."\";");
 349      }
 350  }

I suppose something like this should work (showthread_end)
// Do we have any forum rules to show for this forum?
$forumrules = '';
$foruminfo = &$forum;
if($foruminfo['rulestype'] != 0 && $foruminfo['rules'])
{
	if(!$foruminfo['rulestitle'])
	{
		$foruminfo['rulestitle'] = $lang->sprintf($lang->forum_rules, $foruminfo['name']);
	}

	$rules_parser = array(
		"allow_html" => 1,
		"allow_mycode" => 1,
		"allow_smilies" => 1,
		"allow_imgcode" => 1
	);

	$foruminfo['rules'] = $parser->parse_message($foruminfo['rules'], $rules_parser);
	if($foruminfo['rulestype'] == 1 || $foruminfo['rulestype'] == 3)
	{
		eval("\$rules = \"".$templates->get("forumdisplay_rules")."\";");
	}
	elseif($foruminfo['rulestype'] == 2)
	{
		eval("\$rules = \"".$templates->get("forumdisplay_rules_link")."\";");
	}
}

You will need to cache two templates to avoid queries, also, this if for showthread only, it may be different at newreply, newthread and editpost.
You think anyone (that knows there stuff) here would give me direction on what/where to paste in Patches plugin? I feel people's time is valuable so I'd offer something. Can you do this Omar? And yes I'd want {rules} to parse in showthread, new reply, new thread, and edit post. And I'd want the directions public so anyone could benifits from the mod directions. Hopefully the devs include this optional idea in 2.0.
Just want to say thank you Omar for making me an excellent plugin for this.