1. 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)

Discussion in 'Styling and Customization Questions' started by r1pe, Jul 30, 2014.

  1. r1pe

    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! :)
  2. Brogan

    Brogan XenForo Moderator Staff Member

    r1pe likes this.
  3. r1pe

    r1pe Member

    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.
  4. Brogan

    Brogan XenForo Moderator Staff Member

    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.
    r1pe likes this.
  5. r1pe

    r1pe Member

    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.




    Is that possible?
  6. HWS

    HWS Well-Known Member

    It is possible. We do this since some time. It is just a template edit.
    r1pe likes this.
  7. r1pe

    r1pe Member

    @HWS Awesome! Any chance you could share this modification with the community?
  8. HWS

    HWS Well-Known Member

    You may use code similar to that one:

        <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>
    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.
    r1pe likes this.
  9. pegasus

    pegasus Well-Known Member

    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:
    {xen:calc "round({$tIndex} / 1000, 2)"}K
    That will actually do rounding.
    r1pe likes this.
  10. r1pe

    r1pe Member

    I did it now via jQuery and some Template Edits! Works as well.
    Thanks guys for your suggestions...
  11. arthur007

    arthur007 Member

    Hey how can use this ?? What i need to edit this??
  12. dono

    dono Member

    share it !
  13. HWS

    HWS Well-Known Member

    This is really much too complicated. You can do it with simple template edits and xen:calc.

Share This Page