Template hook not working

I'm trying to create a template hook but it's not working for some reason. I already have a navigation_tabs code event listener running (don't know if it matters).


Listen to Event: template hook
Execute Callback: LIGLivestream_Listener::templateHook
Callback Execution Order: 10
Add-on: Livestream page

PHP:
<?php
[...]
class class LIGLivestream_Listener
{
public static function navigation_tabs(array &$extraTabs, $selectedTabId)
{
[...]
}
 
public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
{
$content = "blahrgh"; //making sure that it's working....
}
}

Does anyone know what could be wrong?
 
This line:

class class LIGLivestream_Listener

Should be:

class LIGLivestream_Listener

And this line:

$content = "blahrgh"; //making sure that it's working....

Should be:

$contents = "blahrgh"; //making sure that it's working....

But be warned: you've not specified what hook you want to hook in to. Technically you will be replacing the contents of every single hook with blahrgh.

Might look interesting! In fact, do it and post a screenshot :p


You'll need something like:

if ($hookName == 'message_user_info_extra')
{

$contents = "blahrgh";


}



Posted from my phone so check what I've typed thoroughly :p
 
This line:

class class LIGLivestream_Listener

Should be:

class LIGLivestream_Listener

And this line:

$content = "blahrgh"; //making sure that it's working....

Should be:

$contents = "blahrgh"; //making sure that it's working....

Posted from my phone so check what I've typed thoroughly :p

The class class part was a mistake in the post (copypaste...) not in the code. Nice find though

It was the variable name... It is one of those things that you never notice but when you show it to someone else they notice it imediatly.
Thanks! You just saved me about 7 hours of staring at code and asking myself why it won't work.
 
Top Bottom