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

r1pe

Member
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! :)
 
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.
 
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.
 
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:
iTGggrR.png


After:
U0MKiSW.png


Is that possible?
 
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.
 
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.
 
Top Bottom