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

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

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

Before


After



Is there maybe a easier way to achieve this?

I found this NumFuzz.js

but how can use this in xF ?
 
Last edited:

Xon

Well-known member
#3
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:

Lawrence

Well-known member
#5
Add title="{$user.like_count}" to the anchor that contains the number.
Xon's example will work with post count, just use $user.message_count in place of $user.like_count
 
#6
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
 

Xon

Well-known member
#7
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.
 

Xon

Well-known member
#9
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}}}
 
#10
Thanks Xon

sorry i mean the code for insert the link and Title



Code:
<a href="{xen:link search/member, '', 'user_id={$user.user_id}'}" class="concealed" rel="nofollow">{xen:number $user.message_count}</a>
 
#13
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">
 

James

Well-known member
#15
You replace the old text with the new text as Xon mentioned. Find the text he says to find, replace it with what he says to replace with.