AUSFIFA
Member
I'm trying to include a PHP header in my forum so that it's consistent with my site. On my main PHP site I have a 100% width header that goes across the top.
I've been following a post in this thread which explains how to do exactly that with template hooks:
http://xenforo.com/community/threads/how-do-i-include-php.14691/#post-192963
I've put my forum into debug mode and have created a new plugin called "AUSFIFA Header". I've created a directory for my plugin and created a class inside of it:
/library/AUSFIFA/AFHeader/AFHeader.php
AFHeader.php looks like this:
My problem occurs when I go to add a new Code Event Listener.
I specify it to listen to event "Template Hook". And then in Execute Callback I write:
AUSFIFA_AFHeader_AFHeader :: includePhpFile
I leave everything else blank.
I click "Save Event Listener" and I get an error message stating:
"The server responded with an error. The error message is in the JavaScript console.".
I check the Server Error Log and I'm getting this Fatal Error:
Why is this happening? Am I missing something?
I've been following a post in this thread which explains how to do exactly that with template hooks:
http://xenforo.com/community/threads/how-do-i-include-php.14691/#post-192963
I've put my forum into debug mode and have created a new plugin called "AUSFIFA Header". I've created a directory for my plugin and created a class inside of it:
/library/AUSFIFA/AFHeader/AFHeader.php
AFHeader.php looks like this:
PHP:
<?php
class AUSFIFA_AFHeader_AFHeader
{
public static function includePhpFile($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
{
if($hookName == 'af_header')
{
ob_start();
require_once('header.php');
$contents .= ob_get_contents();
ob_end_clean();
}
}
}
?>
My problem occurs when I go to add a new Code Event Listener.
I specify it to listen to event "Template Hook". And then in Execute Callback I write:
AUSFIFA_AFHeader_AFHeader :: includePhpFile
I leave everything else blank.
I click "Save Event Listener" and I get an error message stating:
"The server responded with an error. The error message is in the JavaScript console.".
I check the Server Error Log and I'm getting this Fatal Error:
Code:
Error Info
ErrorException: Fatal Error: syntax error, unexpected T_STRING - library/AUSFIFA/AFHeader/AFHeader.php:1
Generated By: Kani, 3 minutes ago
Stack Trace
#0 [internal function]: XenForo_Application::handleFatalError()
#1 {main}
Request State
array(3) {
["url"] => string(65) "http://www.ausfifa.com/forums/admin.php?code-event-listeners/save"
["_GET"] => array(1) {
["code-event-listeners/save"] => string(0) ""
}
["_POST"] => array(13) {
["event_id"] => string(13) "template_hook"
["hint"] => string(0) ""
["callback_class"] => string(25) "AUSFIFA_AFHeader_AFHeader"
["callback_method"] => string(14) "includePhpFile"
["execute_order"] => string(2) "10"
["active"] => string(1) "1"
["description"] => string(0) ""
["addon_id"] => string(0) ""
["event_listener_id"] => string(1) "0"
["_xfToken"] => string(8) "********"
["_xfRequestUri"] => string(42) "/forums/admin.php?code-event-listeners/add"
["_xfNoRedirect"] => string(1) "1"
["_xfResponseType"] => string(4) "json"
}
}
Why is this happening? Am I missing something?