XF 1.4 How can change 1000 posts to 1k??

arthur007

Member
Hey guys,
because of the incredible amount of likes in our forum, we would like to round numbers like Facebook.

Before
iTGggrR.png


After

U0MKiSW.png


Is there maybe a easier way to achieve this?

I found this NumFuzz.js

but how can use this in xF ?
 
Last edited:
It is fairly ugly, but it is doable with styling.

Replace "{xen:number $user.like_count}" with:
Code:
<xen:if is="{$user.like_count} > 1000">
<xen:if is="{$user.like_count} > 10000000">
{xen:number {xen:calc 'round({$user.like_count} / 1000000)'}}M
<xen:else/>
{xen:number {xen:calc 'round({$user.like_count} / 1000)'}}K
</xen:if>
<xen:else/>
{xen:number $user.like_count}
</xen:if>

The templates you'll need to alter (or write a template modification for) are:
  • member_card
  • member_list_item
  • member_view
  • message_user_info
  • spam_cleaner
 
Last edited:
Code:
<xen:if is="{$user.message_count} > 1000">
<xen:if is="{$user.message_count} > 10000000">
{xen:number {xen:calc 'round({$user.message_count} / 1000000)'}}M
<xen:else/>
{xen:number {xen:calc 'round({$user.message_count} / 1000)'}}K
</xen:if>
<xen:else/>
<a href="{xen:link search/member, '', 'user_id={$user.user_id}'}" class="concealed" rel="nofollow">{xen:number $user.message_count}</a>
</xen:if>

make this but link work not
 
Code:
<xen:if is="{$user.message_count} > 1000">
<xen:if is="{$user.message_count} > 10000000">
{xen:number {xen:calc 'round({$user.message_count} / 1000000)'}}M
<xen:else/>
{xen:number {xen:calc 'round({$user.message_count} / 1000)'}}K
</xen:if>
<xen:else/>
<a href="{xen:link search/member, '', 'user_id={$user.user_id}'}" class="concealed" rel="nofollow">{xen:number $user.message_count}</a>
</xen:if>

make this but link work not
You need to have the link statement wrapped around the "{xen:number..." bit.

It is possible to rewrite that mess using {xen:if} so it will be a single statement, and then you just replace the original "{xen:number $user.message_count}" statement.
 
For member_card, member_list_item, member_view, message_user_info, spam_cleaner
Replace
Code:
{xen:number $user.like_count}
with
Code:
{xen:if '{$user.like_count} > 10000000', '{xen:number {xen:calc 'round({$user.like_count} / 1000000)'}}M', {xen:if '{$user.like_count} > 1000', '{xen:number {xen:calc 'round({$user.like_count} / 1000)'}}K', {xen:number $user.like_count}}}

For sidebar_visitor_panel
Replace
Code:
{xen:number $user.like_count}
with
Code:
{xen:if '{$visitor.like_count} > 10000000', '{xen:number {xen:calc 'round({$visitor.like_count} / 1000000)'}}M', {xen:if '{$visitor.like_count} > 1000', '{xen:number {xen:calc 'round({$visitor.like_count} / 1000)'}}K', {xen:number $visitor.like_count}}}
 
Thanks Xon

sorry i mean the code for insert the link and Title

vkVYF33.png


Code:
<a href="{xen:link search/member, '', 'user_id={$user.user_id}'}" class="concealed" rel="nofollow">{xen:number $user.message_count}</a>
 
You just need to replace "{xen:number $user.message_count}" with that long expression in my previous post. Swapping $user.like_count for $user.message_count as required.

That i understand

but where must insert this in the code from you

Code:
<a href="{xen:link search/member, '', 'user_id={$user.user_id}'}" class="concealed" rel="nofollow">
 
Top Bottom