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

XF 1.2 Hook parameters are not updating

Discussion in 'XenForo Questions and Support' started by KamelJabber, Feb 19, 2014.

  1. KamelJabber

    KamelJabber Member

    I'll be honest, maybe this is Widget Framework question? Sorry if its...

    I created a hook in the message template under the signature div like so:
            <xen:hook name="message_below_signature" params="{xen:array 'message_user_id={$message.user_id}','message_id={$messageId}'}"/>
    I then created a new template called "custom_signature_template"
    message_user_id: {$message_user_id}<br/>
    message_id: {$message_id}
    I then created an "[Advanced] Template (without wrapper)" widget.
    Set the template to "custom_signature_template" and the position to "hook:message_below_signature"

    Every single message has the message_user_id & message_id of the first message in the thread.
    I was expecting that each message would receive the parameter values for that specific message.

    Looks like it's almost loading the hook template contents once and feeding it to every hook event?
    Dunno :(

  2. Jeremy

    Jeremy Well-Known Member

    Please direct your questions to the widget framework.
  3. KamelJabber

    KamelJabber Member

    Thanks, I apologize...Since it had to do with hooks I wasn't sure, seems obvious now.

    After working on it for couple hours, I ended up getting rid of the widget anyway and adding the following hook listener:


    class BoG_HookListener

        public static function 
    templateHook($hookName, &$contents, array $hookParamsXenForo_Template_Abstract $template)
    $hookParams as $key => $item)
                        if (
    $key == 'message_user_id'$uid $item;

                    if (!
    $userModel XenForo_Model::create('XenForo_Model_User');
    $user $userModel->getUserById($uid);

    $contents .= $template->create('custom_signature_template'array_merge($template->getParams(), $hookParams, array(user=>$user)));

Share This Page