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

Why can I not extend some classes?

Discussion in 'XenForo Development Discussions' started by Marcus, Aug 16, 2013.

  1. Marcus

    Marcus Well-Known Member

    Some classes like XenForo_Link or XenForo_BbCode_TextWrapper can not be extended. Is there a reason behind this like security or performance (the new hint system might help)?
     
  2. Mike

    Mike XenForo Developer Staff Member

    They're just used statically. Since there's no instantiation, you can't extend them.
     
  3. xf_phantom

    xf_phantom Well-Known Member

    why would you want to extend XenForo_Link?
     
  4. Marcus

    Marcus Well-Known Member

    I want to extend XenForo_Link::buildPublicLink for my Virtual Forums. When a user is browsing a virtual forum with node_id=5, he is actually viewing node_id=3 and all links on the page include a &real_node_id=3. How could I change the pagination links who are created with XenForo_Link::buildPublicLink?

     
  5. xf_phantom

    xf_phantom Well-Known Member

    With extending the forum route:
    link.png
     
  6. Daniel Hood

    Daniel Hood Well-Known Member

    Not to hijack the thread but what tool is that?
     
    RoldanLT likes this.
  7. xf_phantom

    xf_phantom Well-Known Member

    JulianD likes this.
  8. digitalpoint

    digitalpoint Well-Known Member

    It certainly would be nice if any/all classes could be extended, but some things it's just not practical to be able to extend on the fly. Personally, I still have to hack on 5 files (not a major task) on an upgrade.

    These are the ones that I still have to edit the PHP files on...

    library/XenForo/Model/Avatar.php
    library/XenForo/ViewPublic/Helper/User.php
    library/XenForo/ControllerPublic/Abstract.php
    library/XenForo/Helper/String.php
    library/XenForo/CodeEvent.php
     
  9. Marcus

    Marcus Well-Known Member

    Works wonderful ! I forgot routes also extend Link.php.
     
  10. Daniel Hood

    Daniel Hood Well-Known Member

    Is it possible to extend XenForo_Template_Helper_Core?
     
  11. Marcus

    Marcus Well-Known Member

    I know I had some problems doing that one or two years ago, but then I didn't know so much about xenforo either. Some functions could not be extended, not sure if it was a problem with the whole class.
     

Share This Page