I must be running in "luddite" mode this evening. Here's my error message when trying to add a Code Event Listener:
Hmmm. Anyway, my simple add-on is only injecting a new bit of HTML into the <head> of the page. I'm using the page_container_head template hook to do so. Here are the steps I took, with my entries in
italics.
1. Create a directory under Library called
Speakeasy (IOW,
forum/library/Speakeasy/);
2. Create a PHP file within that directory with the code to execute for the addon (I named it Speakeasy_MyTest.php). This code contains the following:
PHP:
<?php
class Speakeasy_MyTest
{
public static function templateHook($hookName, &$contents, $params, XenForo_Template_Abstract $template)
{
if ($hookName == 'page_container_head') {
$contents .= '<link ...my code here... />';
}
}
}
3. Add the add-on, using the exact same name as the directory for the add-on ID ("
Speakeasy") and a description of
Speakeasy Add-on.
4. Add the event listener. I choose Listen to event:
template_hook from the drop-down. For Execute Callback I've entered
Speakeasy_MyTest ::
templateHook in the two fields. Finally, I pick my addon,
Speakeasy Add-on, from the drop-down box at the bottom.
I submit this, and I get the error message above. I am missing one step in all this, I'm sure, or just naming something wrong. I've pretty much followed Kier's example, to the best of my knowledge.
Plus, I have a question--how does the add-on or callback know which directory and file to look in, to find the code within my PHP file? Is this where I'm getting derailed? Does XF load whatever it finds in the library, or did I miss a step that's not in the video perhaps?
Once I get this working, I can further modify it. I just want to get it working per Kier's first example, and then build on it from there.
Thanks for looking!