1. 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

Discussion in 'XenForo Development Discussions' started by AndyB, Oct 28, 2013.

  1. AndyB

    AndyB Well-Known Member

    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 &$messagesXenForo_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
            
        
    }
    }
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    It isn't possible because that class is called statically. It can't be extended.
     
  3. AndyB

    AndyB Well-Known Member

    Thank you, Chris.
     
    Last edited: Oct 29, 2013
  4. developr

    developr Member

    Do you find another solution or workaround?
     
  5. Beanjam

    Beanjam Active Member

    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);
         }
       }
    
     
  6. Beanjam

    Beanjam Active Member

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

Share This Page