• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How can I extend XenForo_ViewPublic_Helper_Message

AndyB

Well-known member
#1
I would like to extend XenForo_ViewPublic_Helper_Message so that I may add my own code to the bbCodeWrapMessages function.

PHP:
public static function bbCodeWrapMessages(array &$messages, XenForo_BbCode_Parser $parser, array $options = array())
{
	$options += array(
		'showSignature' => XenForo_Visitor::getInstance()->get('content_show_signature'),
		'states' => array()
	);

	foreach ($messages AS &$message)
	{
		$message['messageHtml'] = XenForo_ViewPublic_Helper_Message::getBbCodeWrapper($message, $parser, $options);

		// I would like to add code here
		
	}
}
 

Beanjam

Active member
#5
I would also like to know possible workarounds for this please.

I'm trying to add my own message filter to bbCodeWrapMessages before getBbCodeWrapper is called, or is there somewhere else better I can do this?

Code:
  public static function bbCodeWrapMessages(array &$messages, XenForo_BbCode_Parser $parser, array $options = array())
   {
     $options += array(
       'showSignature' => XenForo_Visitor::getInstance()->get('content_show_signature'),
       'states' => array()
     );

     foreach ($messages AS &$message)
     {
       $message['message'] = XenForo_ViewPublic_Helper_Message::MyFilter($message['message']);
       $message['messageHtml'] = XenForo_ViewPublic_Helper_Message::getBbCodeWrapper($message, $parser, $options);
     }
   }
 

Beanjam

Active member
#6
Changed my plans, I found that XenForo_BbCode_Formatter_Base is extendable and the preFilterText function is much better for my purpose.