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

XF 2.0 Math functions in XF2 templates?


Active member
I would replicate this structure URL: <img src="/forum/data/avatars/s/_GROUP_/{$user.user_id}.jpg?{$user.avatar_date}">

As I can see, _GROUP_ can be calculated with this method:

_GROUP_ = floor -> {$user.user_id} / 1000
(ya, this isn't PHP code, I haven't source in front of)

So, the question is: there's a way to use simply math functions in XF2 templates (without scripting it in PHP)?

Chris D

XenForo developer
Staff member
We don't expose everything, but we do actually expose floor (and ceil), so this should work:
<img src="/forum/data/avatars/s/{{ floor($user.user_id / 1000) }}/{$user.user_id}.jpg?{$user.avatar_date}">