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

PHP Includes?

Discussion in 'XenForo Development Discussions' started by emma57573, Apr 7, 2012.

  1. emma57573

    emma57573 Member

    Is there a way to include PHP Includes within the template?

  2. emma57573

    emma57573 Member

    So Ive given the template Hooks a go and have run into an error when adding the code event listener "Please enter a valid callback method."

    I have looked at tutorials and checked my path to the php class file and can't work out whats wrong.

    This is what I have done so far:

    Popped the forum in debug mode.

    Created a php file called plugin.php and placed it in xenforum/library/php/include/plugin.php

    The file looks like this:

    class php_include_plugin
        public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
            if($hookName == 'include_php')
                $contents .= ob_get_contents();

    Checked the permissions on the file and folders were correct

    Now Ive gone to admin>create add-on
    and Ive created an add on called 'include_php'

    Now I go to admin>development>Code event listener

    And clicked on create new listener and set the options as follows:

    Listen to event: template_hook

    Execute Call back: php_include_plugin::templateHook

    Description: PHP Include

    Add on: include_php

    When I save I get Please enter a valid callback method. So somethings not tying up but I can't work out what it is
  3. emma57573

    emma57573 Member

    Fixed silly typo in the function call templateHook (I have now amended it above), amazing how I spend over an hour trying to work it out, then as soon as I see it all written out on the post its so obvious!!! :rolleyes: So thanks this thread has helped me even if no one replied :D
    So refreshing to have a system that I can make edits to without effecting the basic forum structure. Will make my life so much easier for updates!
    Jake Bunce likes this.

Share This Page