Klenkes Posted October 30, 2019 Share Posted October 30, 2019 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 More sharing options...
dragan Posted October 30, 2019 Share Posted October 30, 2019 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. 2 Link to comment Share on other sites More sharing options...
adrian Posted October 30, 2019 Share Posted October 30, 2019 I use: http://modules.processwire.com/modules/fieldtype-phone/ ? 3 Link to comment Share on other sites More sharing options...
AndZyk Posted October 30, 2019 Share Posted October 30, 2019 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. 1 Link to comment Share on other sites More sharing options...
Klenkes Posted October 31, 2019 Author Share Posted October 31, 2019 14 hours ago, adrian said: I use: http://modules.processwire.com/modules/fieldtype-phone/ ? 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 More sharing options...
LostKobrakai Posted October 31, 2019 Share Posted October 31, 2019 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. 1 Link to comment Share on other sites More sharing options...
Klenkes Posted November 1, 2019 Author Share Posted November 1, 2019 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! Link to comment Share on other sites More sharing options...
elabx Posted November 1, 2019 Share Posted November 1, 2019 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 More sharing options...
Recommended Posts