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

XF 2.0 Passing a $user variable to the thread_view template

AndyB

Well-known member
#1
In the thread_view template, is there a direct way for me to use the following variable:

{$user.trader_seller_count}

I have added the field trader_seller_count to the xf_user table and extended the entity.

Thank you.
 

Chris D

XenForo developer
Staff member
#4
{$thread.User} should do it (though you may want to check that actually returns something, in case it's a guest created thread or a deleted user.
 

AndyB

Well-known member
#5
Works perfect. I tried {$thread.user.trader_seller_count} but forgot about the case. The variable User must be uppercase U.

Thank you, Chris.
 

AndyB

Well-known member
#6
In a template what is the proper syntax to add these two variables?

{$thread.User.trader_seller_count} + {$thread.User.trader_buyer_count}
 

Chris D

XenForo developer
Staff member
#7
You probably want this so it formats it as a number (including the thousands separator if necessary)
Code:
{{ ($thread.User.trader_seller_count + $thread.User.trader_buyer_count)|number }}