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

Extending XenForo_Html_Renderer_BbCode, what event to listen to ?

Discussion in 'XenForo Development Discussions' started by allewreK, Aug 29, 2013.

  1. allewreK

    allewreK Active Member

    Hello,

    I would like to redefine a method in the XenForo_Html_Renderer_BbCode class.

    What event do I have to listen to (in code event listener)?

    Best regards.
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    upload_2013-8-30_13-12-59.png

    You need XenForo 1.2 (that's when the load_class event was added).
     
    allewreK likes this.
  3. allewreK

    allewreK Active Member

    Oh great thanks you very much Chris, so the load_class event allow us to load any class :) That's great !
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    Almost any class...

    From the details of the event:

     
    allewreK likes this.
  5. digitalpoint

    digitalpoint Well-Known Member

    Not sure it works with XenForo_Html_Renderer_BbCode... I could be wrong, but I sort of recall I tried it for something and it didn't.
     
  6. Chris D

    Chris D XenForo Developer Staff Member

    It does work. I did a quick test before I suggested it as I wasn't sure myself it would work or not. :)

    I was able to overwrite and extend a couple of functions no problem
     
  7. xf_phantom

    xf_phantom Well-Known Member

    Yes, since xf 1.2 and the new load_class event it's working:)
     
  8. digitalpoint

    digitalpoint Well-Known Member

    Nice... then I guess I need to loop back and see what I did wrong. Probably had a typo or something. :)
     
  9. Marcus

    Marcus Well-Known Member

    The BbCode_TextWrapper is the class one can not extend :)
     
    digitalpoint likes this.
  10. digitalpoint

    digitalpoint Well-Known Member

    Oh yeah... that was it. :)
     
    Marcus likes this.
  11. digitalpoint

    digitalpoint Well-Known Member

    Now if load_class would just work on Helpers... :)
     
  12. Jeremy

    Jeremy XenForo Moderator Staff Member

    Helpers are loaded via direct calls, so a different system would have to be baked in for those.
     
  13. allewreK

    allewreK Active Member

    I can confirm you that I correctly extended the class XenForo_Html_Renderer_BbCode.
     
  14. Marcus

    Marcus Well-Known Member

    It works, the class BbCode_TextWrapper doesn't like to be extended. It took me some time to figure it out, that it was entirely not possible :D I am very thankful to the great community here where experienced developers help out beginners.
     
    Daniel Hood likes this.
  15. allewreK

    allewreK Active Member

    And to extend XenForo_Router::math method, what should I listen to? :/
     
  16. Chris D

    Chris D XenForo Developer Staff Member

    Doesn't load_class work for that?
     
  17. allewreK

    allewreK Active Member

    I tried but didn't succed. If you use load class, and dump the class you have, you won't find any xenforo_router.
     
  18. xf_phantom

    xf_phantom Well-Known Member

    event load_class_route_prefix ?
     
    allewreK likes this.
  19. allewreK

    allewreK Active Member

    Nice find, it may do the job but we can't extend XenForo_Router with load_class_route_prefix.
     
  20. xf_phantom

    xf_phantom Well-Known Member

    There is no XenForo_Route class?!
     

Share This Page