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

Looking for the user ID for custom template.

F

Floris

Guest
#1
To show an icon next to the name in a post, linking directly to the profile.
I made a Listener.php that injects my own template in the hook at message_user_info_text
I use .css to mark it up.

It's very basic, but a crucial element the user id isn't available or I simply don't know which to use.

Attached is the 100b1 I have so far, consider it alpha. Looking forward for the 'doh' moment. Because I know it's something very simple.

I've tried {$user.user_id} , {$message.username} , {$xen:help user_id, $user} and a few other things I don't remember atm.

Reference: related to this thread. http://xenforo.com/community/thread...ink-to-users-profile-page-from-postbit.19954/
 

Attachments

R

ragtek

Guest
#2
You need to user_id which is sent to the template hook event listener via

params="{xen:array 'user={$user}'

so inside your template hook you need to add this to the viewparam array

PHP:
    public static function templateHook($name, &$contents, array $params, XenForo_Template_Abstract $template)
    {
        // $options = XenForo_Application::get('options'); // lets get those options
        // $options->xenfans_profilethingy_whateveroption == 1
            switch ($name)
            {
                case 'message_user_info_text':
                {
                 
                    $viewParams = array_merge($template->getParams(), $params); // then you have access
                    $temp_contents = $template->create('xenfans_profilethingy', $viewParams);
                    break;
                }
            } // swtich
            $contents = $temp_contents . $contents;

    } // end public
 // end class
# EOF