XenForo [JoyFreak] Thread view/reply count

JoyFreak

Administrator
Live example: Gaming Forums

Description
This guide will run you through on how to display the number of views and replies in the thread description.

Guide
  1. Go to Admin CP > Appearance > Templates > Search: thread_view

Find:
Code:
<a href="{{ link('threads', $thread) }}" class="u-concealed"><xf:date time="{$thread.post_date}" /></a>
        </li>

Add below (choose one from below):

Full number, without comma:
Code:
<li title="Replies">
            <i class="fa--xf far fa-reply" aria-hidden="true" title="Replies"></i>
            <span class="u-srOnly">{{ phrase('replies') }}</span>
            {$thread.reply_count}
        </li>

        <li title="Views">
            <i class="fa--xf far fa-eye" aria-hidden="true" title="Views"></i>
            <span class="u-srOnly">{{ phrase('views') }}</span>
            {$thread.view_count}
        </li>

Full number, with comma:
Code:
<li title="Replies">
            <i class="fa--xf far fa-reply" aria-hidden="true" title="Replies"></i>
            <span class="u-srOnly">{{ phrase('replies') }}</span>
            {$thread.reply_count|number}
        </li>

        <li title="Views">
            <i class="fa--xf far fa-eye" aria-hidden="true" title="Views"></i>
            <span class="u-srOnly">{{ phrase('views') }}</span>
            {$thread.view_count|number}
        </li>

Short number:
Code:
<li title="Replies">
            <i class="fa--xf far fa-reply" aria-hidden="true" title="Replies"></i>
            <span class="u-srOnly">{{ phrase('replies') }}</span>
            {$thread.reply_count|number_short}
        </li>

        <li title="Views">
            <i class="fa--xf far fa-eye" aria-hidden="true" title="Views"></i>
            <span class="u-srOnly">{{ phrase('views') }}</span>
            {$thread.view_count|number_short}
        </li>

Screenshot
Full number, without comma
replies-views.png
Full number, with comma
replies-views-comma.png

Live example: Gaming Forums
 
Great resource, I'll probably implement it.
But I would use XF syntax for FA icons instead. This allows them to automatically follow the weight directive defined in the XF style properties.

HTML:
<xf:fa icon="fa-reply" aria-hidden="true" title="Replies" />

instead of...

<i class="fa--xf far fa-reply" aria-hidden="true" title="Replies"></i>
 
Back
Top