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

Discussion in 'Styling and Customization Questions' started by arthur007, Aug 14, 2015.

  1. arthur007

    arthur007 Member

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

    Before
    [​IMG]

    After

    [​IMG]

    Is there maybe a easier way to achieve this?

    I found this NumFuzz.js

    but how can use this in xF ?
     
    Last edited: Aug 14, 2015
    HenrikHansen likes this.
  2. Amaury

    Amaury Well-Known Member

    It would likely require custom development or an add-on.
     
  3. Xon

    Xon Well-Known Member

    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: Aug 14, 2015
    arthur007 and Amaury like this.
  4. arthur007

    arthur007 Member

    Nice Thanks :) have you a idea how see the real like stats in howover ?? And works this with Post Count?

    Example

    [​IMG]
     
  5. Lawrence

    Lawrence Well-Known Member

    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
     
    arthur007 likes this.
  6. arthur007

    arthur007 Member

    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
     
  7. Xon

    Xon Well-Known Member

    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.
     
  8. arthur007

    arthur007 Member

    Can you describe to me the code?
    i find not the right please for " title="{$user.like_count}" "
     
  9. Xon

    Xon Well-Known Member

    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}}}
    
     
    rafass likes this.
  10. arthur007

    arthur007 Member

    Thanks Xon

    sorry i mean the code for insert the link and Title

    [​IMG]

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

    arthur007 Member

    No one?
     
  12. Xon

    Xon Well-Known Member

    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.
     
  13. arthur007

    arthur007 Member

    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">
     
  14. arthur007

    arthur007 Member

    No Idea Xon?
     
  15. James

    James Well-Known Member

    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.
     
    Xon likes this.
  16. arthur007

    arthur007 Member

    [​IMG]

    but the Code from Xon have no howover
     
  17. arthur007

    arthur007 Member

    No idea?
     
  18. arthur007

    arthur007 Member

    ??? No One
     

Share This Page