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

parent::renderHtml()

Discussion in 'XenForo Development Discussions' started by Jake Bunce, Sep 9, 2013.

  1. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I am extending:

    XenForo_ViewAdmin_Node_List

    This class is not defined in the default software so I don't need to call the parent in my extended function. But there is the case of other addons also extending this class in which case a parent call needs to be in place. Because the parent may not exist I need some condition to check the existence of the parent function. I have tried a few things including method_exists() and is_callable() but it's not working. The 'parent' keyword doesn't seem to work for such a check in this context.

    Ideas?
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    Does it throw an error that the function doesn't exist?

    Try:
    PHP:
    method_exists(get_parent_class($this), 'renderHtml')
     
    Adam Howard and Jake Bunce like this.
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That works.
     
    Adam Howard likes this.
  4. Dan

    Dan Well-Known Member

  5. xfrocks

    xfrocks Well-Known Member

    No it will not...
     
    Jake Bunce likes this.
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Thank you sir. I am using your code now.
     

Share This Page