The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Make fields display like this

Go down

Solved Make fields display like this

Post by Zuke on 15/1/2016, 20:09

Hello, I'd like for the posts, credits and reputation to look like this:

http://prntscr.com/9qiyhn

When the posts are like this, it replaces what would of looked like this:

http://prntscr.com/9qizd4

K = Thousand

M = Million


Any help? Thanks!

Tagging: @Ange Tuteur


Last edited by Zuke on 21/1/2016, 22:46; edited 1 time in total
avatar
Zuke
Forumember

Male Posts : 385
Reputation : 21
Language : English
Location : United Kingdom

http://droplet.your-talk.com

Back to top Go down

Solved Re: Make fields display like this

Post by Zuke on 21/1/2016, 20:59

Bump!
avatar
Zuke
Forumember

Male Posts : 385
Reputation : 21
Language : English
Location : United Kingdom

http://droplet.your-talk.com

Back to top Go down

Solved Re: Make fields display like this

Post by 10spetter10 on 21/1/2016, 22:08

I'm not the best coder but try this.

First you need to make a small change to your template 'viewtopic_body'. I see you have a custom one so I can't really say exactly where you'll find it, but search for.
Code:
{postrow.displayed.profile_field.LABEL}{postrow.displayed.profile_field.CONTENT}{postrow.displayed.profile_field.SEPARATOR}

code around, so you can find it better:
Code:
<div class="author-stats">
   {postrow.displayed.ONLINE_IMG}
   <!-- BEGIN profile_field -->
      {postrow.displayed.profile_field.LABEL}{postrow.displayed.profile_field.CONTENT}{postrow.displayed.profile_field.SEPARATOR}
   <!-- END profile_field -->
   {postrow.displayed.POSTER_RPG}
</div>

And replace it by:
Code:
{postrow.displayed.profile_field.LABEL}<span class="value">{postrow.displayed.profile_field.CONTENT}</span>{postrow.displayed.profile_field.SEPARATOR}

Then add this javascript with placing 'on the topics':
Code:
$(function() {
    $('.author-stats .value').each(function() {
          var newVal = nFormatter($(this).html());
          $(this).html(newVal);
    });
});
function nFormatter(num) {
    if (num >= 1000000000) {
        return (num / 1000000000).toFixed(1).replace(/\.0$/, '') + 'G';
    }
    if (num >= 1000000) {
        return (num / 1000000).toFixed(1).replace(/\.0$/, '') + 'M';
    }
    if (num >= 1000) {
        return (num / 1000).toFixed(1).replace(/\.0$/, '') + 'K';
    }
    return num;
}
avatar
10spetter10
Forumember

Posts : 195
Reputation : 82
Language : Dutch

Back to top Go down

Solved Re: Make fields display like this

Post by Zuke on 21/1/2016, 22:36

@10spetter10 wrote:I'm not the best coder but try this.

First you need to make a small change to your template 'viewtopic_body'. I see you have a custom one so I can't really say exactly where you'll find it, but search for.
Code:
{postrow.displayed.profile_field.LABEL}{postrow.displayed.profile_field.CONTENT}{postrow.displayed.profile_field.SEPARATOR}

code around, so you can find it better:
Code:
<div class="author-stats">
   {postrow.displayed.ONLINE_IMG}
   <!-- BEGIN profile_field -->
      {postrow.displayed.profile_field.LABEL}{postrow.displayed.profile_field.CONTENT}{postrow.displayed.profile_field.SEPARATOR}
   <!-- END profile_field -->
   {postrow.displayed.POSTER_RPG}
</div>

And replace it by:
Code:
{postrow.displayed.profile_field.LABEL}<span class="value">{postrow.displayed.profile_field.CONTENT}</span>{postrow.displayed.profile_field.SEPARATOR}

Then add this javascript with placing 'on the topics':
Code:
$(function() {
    $('.author-stats .value').each(function() {
          var newVal = nFormatter($(this).html());
          $(this).html(newVal);
    });
});
function nFormatter(num) {
    if (num >= 1000000000) {
        return (num / 1000000000).toFixed(1).replace(/\.0$/, '') + 'G';
    }
    if (num >= 1000000) {
        return (num / 1000000).toFixed(1).replace(/\.0$/, '') + 'M';
    }
    if (num >= 1000) {
        return (num / 1000).toFixed(1).replace(/\.0$/, '') + 'K';
    }
    return num;
}
Thank you! Works like a charm!
avatar
Zuke
Forumember

Male Posts : 385
Reputation : 21
Language : English
Location : United Kingdom

http://droplet.your-talk.com

Back to top Go down

Solved Re: Make fields display like this

Post by SLGray on 22/1/2016, 01:43

Topic solved and archived


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 42731
Reputation : 3010
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum