XF 1.5 Why Isn't This Template Hook Working?

king8084

Well-known member
listen to event: template_hook
event hint: message_user_info_text
callback: PosterOfMonth_Listener::userInfoHook

Code:
<?php

class PosterOfMonth_Listener
{

public static function userInfoHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        if($hookName == 'message_user_info_text')
        {
            //Creating the template
            $pomTemplate = $template->create('ls_pom_winner_ribbon', $template->getParams());
         
            //Getting the previous month winner from the model
            $user = XenForo_Model::create('PosterOfMonth_Model_PosterOfMonth')->getPreviousMonthWinner();
            //Attaching the params to the template
            $pomTemplate->setParam('winner', $user[0]);
            //Attaching the hookParams passed to function as params as well
            $pomTemplate->setParams($hookParams);
         
            //Rendering the template
            $render = $pomTemplate->render();
         
            //Appending the render to the content
            $contents .= $render;
        }
    }
}

inside message_user_info template:
Code:
<xen:hook name="message_user_info_text" params="{xen:array 'user={$user}'}" />


...however, the $winner variable isn't accessible

What am I missing?
 
Last edited:
Top Bottom