• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Commas in a number field

Community Beginner ,
Jan 05, 2015 Jan 05, 2015

Copy link to clipboard

Copied

I have developed a web site for a real estate agency for which I have built a custom web app. The web app has a number fields that display information about individual properties in both list and detail formats. Some of the fields I created in the web app are "number" fields. I used number fields for price and square feet because I also have a search form linked to the web app. I needed to have a min and max search capability for these two fields, which the "number" field provides automatically. However, being a "number" field, it does not allow for the use of commas in the field, which is a client requirement. If a comma is used in the web app field, the display is null. For example, the client needs the price to be displayed like this (1,300,000) vs (1300000). Here is a link to the test site: Anne Rogers Realty Group, Inc - Featured Listings.  Note the price and square feet fields on both the list an detail views for the properties. Is there any way around this problem? Thanks in advance

TOPICS
Web apps

Views

3.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 05, 2015 Jan 05, 2015

Hi Murray,

Business Catalyst is not PHP based, nor do you have access to server side code. It does not work like that so you cant do that.

For the original poster - If you really need them to be numbers for the search you only have a few options..

- Enable the beta liquid feature and use that to manipulate the output

- Do it with javascript

- Leave it as is

- Create text fields of the prices as well for display and the number fields for search.

Votes

Translate

Translate
LEGEND ,
Jan 05, 2015 Jan 05, 2015

Copy link to clipboard

Copied

Why can't you put the commas in for display, and remove them on submit?

Something like - $number = 1234.56; echo number_format($number,2,'.','.');

//string number_format ( float $number , int $decimals = 0 , string $dec_point = "." , string $thousands_sep = "," )

And then on submit, str_replace(',','',$_POST[numberField])

Would that work?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 05, 2015 Jan 05, 2015

Copy link to clipboard

Copied

Hi Murray,

Business Catalyst is not PHP based, nor do you have access to server side code. It does not work like that so you cant do that.

For the original poster - If you really need them to be numbers for the search you only have a few options..

- Enable the beta liquid feature and use that to manipulate the output

- Do it with javascript

- Leave it as is

- Create text fields of the prices as well for display and the number fields for search.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 05, 2015 Jan 05, 2015

Copy link to clipboard

Copied

Thanks, Liam. I missed that completely!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 07, 2015 Jan 07, 2015

Copy link to clipboard

Copied

Thanks Liam. Looks like creating text fields of the prices as well for display and the number fields for search is the way to go to accomplish what I needed. Why didn't I think of that!?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 05, 2015 Feb 05, 2015

Copy link to clipboard

Copied

Well you can do anything from developer's perspective but asking client to put same value twice can make you look unprofessional.

Here's what I did for many house listing websites.

1. Client puts price in pure number format ( e.g. 500000 )

2. wrap the price value with a tag in List/Detail template e.g.   <span class="house-price">{tag_price}</span>

3. then at the end of the page put a jQuery snippet which would globally format the prices ( e.g. $('.house-price').formatCurrency(); )

   Here's one I use

  https://code.google.com/p/jquery-formatcurrency/

   even if you're not familiar with jQuery it's pretty easy to follow

No more complain from client

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 05, 2015 Feb 05, 2015

Copy link to clipboard

Copied

Or you use liquid now and use data types and not have to do that

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 06, 2015 Feb 06, 2015

Copy link to clipboard

Copied

Great Liam! And now, could you explain us exactly how you would do that?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 06, 2015 Feb 06, 2015

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 06, 2015 Feb 06, 2015

Copy link to clipboard

Copied

Thanks Liam!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 12, 2015 Feb 12, 2015

Copy link to clipboard

Copied

I'm using liquid to format my number to the currency format. However the commas are not showing up. Is there a way to force it to show?

Shopify has custom formats like money_with_comma_seperators, however I do not think BC has this..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 12, 2015 Feb 12, 2015

Copy link to clipboard

Copied

Depending on currency, since BC runs its prices on culture would be your to manage where you split and display as you need to and that is quite straight forward.


Liquid is data and its just data so its up to use to use it and display as we need. It wont happen like magic like tags

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 12, 2015 Feb 12, 2015

Copy link to clipboard

Copied

Edit:

I've tried:

currency: USD

currency: 'USD'

convert:'USD'

and they couldn't work.

Do I have to use javascript to do the splitting instead?

So if I wanted to display it as USD then I would do it as {{price | currency:USD | remove: '.00'}}?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 13, 2015 Feb 13, 2015

Copy link to clipboard

Copied

You need to read the BC documentation:

Developer reference

Currency does not work like that and how your using it.

You need to use the split filter and manipulate as you need to etc.. Use what is documented, not anything else.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 13, 2015 Feb 13, 2015

Copy link to clipboard

Copied

Ok thanks for the clarification!! 😃

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 13, 2015 Feb 13, 2015

Copy link to clipboard

Copied

{% if this.price > 999999 %}

    <span class="price">{{price | divided_by: 1000000  | currency | remove: '.00'}},{{price | modulo:1000000 | divided_by:100000}}{{price | modulo:100000 | divided_by:10000}}{{price | modulo:10000 | divided_by:1000}},{{price | modulo:1000 | divided_by:100}}{{price | modulo:100 | divided_by:10}}{{price | modulo:10 | divided_by:1}}

{% elseif this.price > 999 %}

    <span class="price">{{price | divided_by: 1000  | currency | remove: '.00'}},{{price | modulo:1000 | divided_by:100}}{{price | modulo:100 | divided_by:10}}{{price | modulo:10 | divided_by:1}}

{% else %}

    <span class="price">{{price | currency | remove: '.00'}}

{% endif %}

Here's the code.. If anyone is interested

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 13, 2015 Feb 13, 2015

Copy link to clipboard

Copied

LATEST

That is first round, go through it again and you can simplify that a lot, Like I said, split is one element for that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines