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

View previous topic View next topic 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

Zuke
Forumember

Male Posts : 379
Reputation : 20
Language : English
Location : United Kingdom

http://ocean.forums.fm

Back to top Go down

Solved Re: Make fields display like this

Post by Zuke on January 21st 2016, 8:59 pm

Bump!

Zuke
Forumember

Male Posts : 379
Reputation : 20
Language : English
Location : United Kingdom

http://ocean.forums.fm

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;
}

10spetter10
Forumember

Posts : 195
Reputation : 81
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!

Zuke
Forumember

Male Posts : 379
Reputation : 20
Language : English
Location : United Kingdom

http://ocean.forums.fm

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.


SLGray
Administrator
Administrator

Male Posts : 36648
Reputation : 2443
Language : English
Location : United States

http://ztwds.forumotion.com/

Back to top Go down

View previous topic View next topic Back to top


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