Forum Discussion

bhupen's avatar
bhupen
Advisor
10 years ago

Commas in Numbers Activity on Front Page

Hi

I want to show my API result in comma seprated:

I got the online user in community using following API.

 

<#assign users = rest("/users/online/count").value />
<h3 class="user_online">${users} &nbsp;Users Now Online</h3

 

Output for the above API: 8484638

 

Requiement: I need to display out in comma seprated:

For example: instead of displying 8484638, it should display as 8,484,638.

  • Guyz this is resolved just set up the locale and put ?eval with your string.

     

    <#setting number_format=",##0">
    <#setting locale="en_US">
    <h3 class="conv_on">${posts?eval}

     

    hope this may help someone else.

     

    Cheers!

    • bhupen's avatar
      bhupen
      Advisor

      VarunGrazitti  Some how its helpful but still not achived the success. I got the way but its not working at my end.

       

      Way 1:

      <#assign posts = rest("/topics/count").value />
      <#setting posts_format=",##0.00">
      <#setting locale="en_US">
      <h3 class="conv_on">${posts }Conversations To Join</h3>

       

      Way 2:

      <#assign users = rest("/users/online/count").value />
      <#setting users.setNumberFormat=",##0.00">
      <#setting locale="en_US">
      <h3 class="user_online">${users} Users Now Online</h3>

       

      Both not working.

       

      • bhupen's avatar
        bhupen
        Advisor

        Guyz this is resolved just set up the locale and put ?eval with your string.

         

        <#setting number_format=",##0">
        <#setting locale="en_US">
        <h3 class="conv_on">${posts?eval}

         

        hope this may help someone else.

         

        Cheers!