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

Override XenForo_ViewPublic_Helper_Message

Discussion in 'XenForo Development Discussions' started by vbgamer45, Dec 26, 2010.

  1. vbgamer45

    vbgamer45 Active Member

    Trying to make an addon that overrides XenForo_ViewPublic_Helper_Message but can't seem to get it to pickup. Not sure if I am using the right event_id or if I can even override that function.

    Have this in the addon xml file
    Code:
      <code_event_listeners>
        <listener event_id="load_class_view" execute_order="10" callback_class="registeredlinks_Listener_LoadClassView" callback_method="loadClassListener" active="1" description="Listens for XenForo_ViewPublic_Helper_Message class"/>
     </code_event_listeners>
    Then have this in the Listener
    Code:
    class registeredlinks_Listener_LoadClassView
    {
            public static function loadClassListener($class, &$extend)
            {
    
                if ($class == 'XenForo_ViewPublic_Helper_Message')
                {
                  $extend[] = 'registeredlinks_ViewPublic_registeredlinks';
                }
    
            }
    
    }
    
    Directory structure is library\registeredlinks\ViewPublic\registeredlinks.php
     
  2. Shadab

    Shadab Well-Known Member

    That's a view helper; not a view class itself. So it can't be extended using the load_class_view event.
     
  3. vbgamer45

    vbgamer45 Active Member

    No other way to override it? Otherwise I would have to hook into bbcode but really only wanted it to affect messages only and not all bbcode parsing areas.
     
  4. Shadab

    Shadab Well-Known Member

    Unfortunately no. And since the methods contained in these helpers are used statically, it would've been hard to override them effectively anyway. Btw, this particular helper is used in the following view classes:
    • ViewPublic/Conversation/View.php
    • ViewPublic/Conversation/ViewNewMessages.php
    • ViewPublic/Thread/View.php
    • ViewPublic/Thread/ViewNewPosts.php
    • ViewPublic/Thread/ViewPosts.php
    ...so you can try extending these classes individually to achieve the same thing.
    Not ideal. But it would work.
     
  5. vbgamer45

    vbgamer45 Active Member

    Shadab I ended up doing what you suggested.
     

Share This Page