Jump to content

How do you handle telephone numbers?


Klenkes
 Share

Recommended Posts

Phone numbers clickable, touchable, dialable... the correct format would be something like:

<a href="tel:0049123456789">+49 (0)1234 56789</a>

But how to handle all the different formats?
From within Germany I need the leading zero 01234 but from outside Germany not.
And the presentation should obviously not be 0049123456789 but the more readable +49 (0)1234 5678

How do you manage the data within Processwire?

Link to comment
Share on other sites

Actually, for href the correct format is +49 (country prefix). The leading numbers don't matter (same as for the leading zero after the country prefix). 

1 hour ago, Klenkes said:

How do you manage the data within Processwire?

I know I could use an HTML5 regex pattern, but actually I just do an instruction text below the input field, with an example.

  • Like 2
Link to comment
Share on other sites

I leave that to the browsers. Most mobile browsers do convert automatically a phone number to a phone link.

So only if you want to offer phone links to desktop browsers, you need to insert the link manually. 

Edit: Ok, not most browsers. Safari does convert phone numbers, but others don't, it seems. So a link is safer.

  • Like 1
Link to comment
Share on other sites

14 hours ago, adrian said:

Found the module yesterday and trying it out today.
My current project has 28 members in an association and they have to manage their profile pages with addresses and contact information. They will have the possibility to input 4 different phone numbers, so everything has to be fool proof! They expect that a visitor can tip a phone number(on a mobile device) an call them directly.

15 hours ago, dragan said:

Actually, for href the correct format is +49 (country prefix). The leading numbers don't matter (same as for the leading zero after the country prefix). 

I didn't know that!
I guess I have to do a static page somewhere and try different versions of numbers out. Call myself...

13 hours ago, AndZyk said:

Edit: Ok, not most browsers. Safari does convert phone numbers, but others don't, it seems. So a link is safer.

I borrowed my brothers iPhone yesterday and no number on my testpage worked so far (list of skulls and other swear symbols)

Thanks for the insight!

Link to comment
Share on other sites

Usually I'd say the best approach if you need multiple formats is storing the information in a canonial format and using different formatters, which can convert the canonical format the the various output formats you have. Kinda like e.g. datetimes are stored as unix timestamp, but that's hardly ever the output format.

  • Like 1
Link to comment
Share on other sites

On 10/31/2019 at 9:54 AM, LostKobrakai said:

Usually I'd say the best approach if you need multiple formats is storing the information in a canonial format and using different formatters, which can convert the canonical format the the various output formats you have. Kinda like e.g. datetimes are stored as unix timestamp, but that's hardly ever the output format.

Yep. This would be the correct approach. But a little above my skillset.

Since I am running out of time with this project, I went with the ProFields Table module.
+ no fixed amount of fields for numbers
+ versatile with field types
+ entries are easy to manage by the noob members.
- I had to do my own PHP logic to remove non-numerical characters and to format the dialable numbers
But it works!

phones-in-table.PNG.042408ac2e8ab4f645b33abb40ad612a.PNG

Link to comment
Share on other sites

I've used cleave.js for this a couple times (though with currency formatter, but i see phone formaters too) and it's pretty straightforward to integrate through custom javascript. AdminOnSteroids does this for text fields too, but since I was also using a Table module, had to go and write a bit of js. And as @LostKobrakai suggests, before submission i just remove the formatters and save the fields with just their numerical values. 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...