Make fields display like this

Go down

Solved Make fields display like this

Post by Zuke on January 15th 2016, 8:09 pm

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 January 21st 2016, 10:46 pm; 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 January 21st 2016, 8:59 pm

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 January 21st 2016, 10:08 pm

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 January 21st 2016, 10:36 pm

@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 January 22nd 2016, 1:43 am

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 : 43481
Reputation : 3090
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Back to top


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