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

Template Hook Question

Itworx4me

Well-known member
#1
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
 

Arik

Well-known member
#2
You're passing a variable $contents into the function. Then, within the function, you're modifying the variable $content.
 

Arik

Well-known member
#4
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');
 

Itworx4me

Well-known member
#5
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
 

Arik

Well-known member
#6
The method signature that he copied out of his admin is different than what's in mine. Likely yours, too, given what you coded.
 

Itworx4me

Well-known member
#8
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
 

Itworx4me

Well-known member
#12
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());
        }
    }
}