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

Template hook not working

Discussion in 'XenForo Development Discussions' started by Jamie Corcoran, Jul 24, 2012.

  1. 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

    class class 
    public static function 
    navigation_tabs(array &$extraTabs$selectedTabId)
    public static function 
    templateHook($hookName, &$contents, array $hookParamsXenForo_Template_Abstract $template)
    $content "blahrgh"//making sure that it's working....
    Does anyone know what could be wrong?
  2. Chris D

    Chris D XenForo Developer Staff Member

    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
    Jamie Corcoran likes this.
  3. 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.
    Chris D likes this.

Share This Page