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

XF 1.3 Facebook Like Counter for XF (1K instead of 1,000)

#1
Hey guys,
because of the incredible amount of likes in our forum, we would like to round numbers like Facebook does:
1,000 Likes become 1K Likes
I couldn't find a add-on for this...

So, in order to modify xen:numbers function, I have to use a helper, right?
Modifying the core file is not really a solution.

Any suggestions how to develop such a helper?
Is there maybe a easier way to achieve this?

@Kier It would be great to have a option for this in XF 1.4! :)
 
#3
Oh, yeah thats right.
There it's working, but it's not doing the same thing for the numbers in the postbit, for example. Or in the user profile area in the sidebar.

Is it possible to use the helper that is used for the button_count? Where do I find it?
I'm talking about the Xenforo Like System, not the Facebook plugin.

It would be great to have the numbers of the Xenforo Likes rounded like at Facebook.
Thanks Brogan! Really appreciate your help.
 

Brogan

XenForo moderator
Staff member
#4
The profile page uses the same code and layout - button_count.

The message user info block doesn't have a FB like button in it by default, so presumably that is from an add-on or customisation.
 
#5
I think I confused you a little bit.
Let me explain: I want to make the Xenforo Likes/Message numbers look like the numbers on Facebook.

Example...

Before:


After:


Is that possible?
 

HWS

Well-known member
#8
You may use code similar to that one:

Code:
    <xen:if is="{$tIndex} < 1000">
        <xen:set var="$tIndexVal">{xen:number $tIndex}</xen:set>
    <xen:else />
        <xen:set var="$tIndexVal">{xen:number {xen:calc "({$tIndex} - 499) / 1000"}}k</xen:set>
    </xen:if>
You cannot just copy the code but have to modify it to reformat the message counter directly. But it may give you an idea how to accomplish it.
 

pegasus

Well-known member
#9
I'm pretty sure that will show 0.5k likes for a user that actually has 1k. Looking at the stuff in the template compiler, you probably want to use this instead:
Code:
{xen:calc "round({$tIndex} / 1000, 2)"}K
That will actually do rounding.