Template Hook Question

Itworx4me

Well-known member
I am trying to add a bigfooter to the bottom of my site using templateHook. Everything seems to look ok but the footer doesn't show at the bottom of the site. I setup the Code Event Listener. Will someone take a look and tell me if the code looks correct?

PHP:
<?php

class RPMfooter_Listener
{
    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        if($hookName == 'footer')
        {
            $content .= $template->create('RPM_bigfooter');
        }
    }
}

Thanks,
Itworx4me
 
You're passing a variable $contents into the function. Then, within the function, you're modifying the variable $content.
 
You're passing a variable $contents into the function. Then, within the function, you're modifying the variable $content.
I was just following Kier video instructions. So how should the code look?

Thanks,
Itworx4me
 
Ha! So, that's what's going on...You're the second person I've seen whose made this mistake.

Code:
$contents .= $template->create('RPM_bigfooter');
 
Ha! So, that's what's going on...You're the second person I've seen whose made this mistake.

Code:
$contents .= $template->create('RPM_bigfooter');
Very weird because in his video it shows $content not $contents. Wonder why is worked then...lol
 
The method signature that he copied out of his admin is different than what's in mine. Likely yours, too, given what you coded.
 
I tried adding this to the listener:
PHP:
$contents .= $template->create('RPM_bigfooter', $template->getParam);
And I get this error:
Code:
Template Errors: PAGE_CONTAINER
Argument 2 passed to XenForo_Template_Abstract::create() must be an array, null given, called in /home/library/RPMfooter/Listener.php on line 17 and defined in /home/library/XenForo/Template/Abstract.php, line 102:
101: ';
102: $__compilerVar4 = '';
103: $__compilerVar4 .= '
Argument 2 passed to XenForo_Template_Abstract::__construct() must be an array, null given, called in /home/library/XenForo/Template/Abstract.php on line 105 and defined in /home/library/XenForo/Template/Abstract.php, line 80:
79: '0' => XenForo_Template_Helper_Core::callHelper('stripHtml', array(
80: '0' => $pageDescription['content']
81: )),
Argument 2 passed to RPMfooter_Listener::templateCreate() must be an array, null given in /home/library/RPMfooter/Listener.php, line 5:
4: <head>
5: ';
6: $__compilerVar1 = '';

Following Kier's video again ....lol

Can someone let me know what the fix is?

Thanks,
Itworx4me
 
PHP:
$template->getParams()

getParams is a function.
Thanks Arik for the help. I think Kier needs to redo his video on Template Hooks. It would be helpful to get the right code to get the hook system to work correctly.

Thanks again,
Itworx4me
 
If you've got it working, might want to post the code so that others who may have issues have someplace to look.
 
Here is the code that I used to get the TemplateHook to work:

PHP:
<?php

class RPMfooter_Listener
{
    public static function templateCreate($templateName, array &$params, XenForo_Template_Abstract $template)
    {
        if ($templateName == 'PAGE_CONTAINER')
        {
            $template->preloadTemplate('RPM_bigfooter');
        }
    }

    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        if($hookName == 'footer')
        {
            $contents .= $template->create('RPM_bigfooter', $template->getParams());
        }
    }
}
 
Top Bottom