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

Getting output from PHP in XF - Could not execute callback

Discussion in 'XenForo Development Discussions' started by GazCBG, Sep 10, 2015.

  1. GazCBG

    GazCBG Member

    Hi,

    I am trying to get an output from PHP into the side bar, this is my test code

    Location: library/GazCBG/Example/index.php
    Code:
    <?php
    
    class Example_Test_Index {
       public static function getHtml() {
         $output = 'Hello World';
         return $output;
       }
    }
    
    ?>
    
    Then I created a template with
    Code:
    <xen:callback class="Example_Test_Index" method="getHtml"></xen:callback>
    
    Then added add a widget to the side bar and included the template and I get

    Could not execute callback Example_Test_Index::getHtml() - Not callable.


    My end goal is to add a script to the PHP code that output HTML for a Twitch Status.
    I have the Twitch Status script working in normal PHP

    Thanks
     
  2. Snog

    Snog Well-Known Member

    You class should be called GazCBG_Example_index and callback should be GazCBG_Example_index in the template.

    Class and callback names are the path within the library folder.
     
    GazCBG likes this.
  3. GazCBG

    GazCBG Member

    That got it, thank you :)
     
    Snog likes this.

Share This Page