I'm using this excellent module for a database containing listings from multiple countries which will wind up in a book. I thought at one stage I'd have to complete all the missing country-formatting files but fortunately for me the editor has decided that it's better to have a standard phone number format: +123 1234567890 (ie plus, country code, space, and the rest of the number with no spaces).

First stage of this is easy - just get rid of all the phone.xx.inc files. Now I'm getting what I want except there's a hyphen rather than a space, eg +1-5145645056 rather than +1 5145645056.

I've found where it seems to be coded - API.php, line #138 - and have replaced
$phone = $cc['code'] . '-' . $item['number'];
with
$phone = $cc['code'] . ' ' . $item['number'];
and cleared the cache, but I'm still seeing the hyphen.

Any suggestions please? Am I missing it somewhere else?

Comments

ckng’s picture

Status: Active » Fixed

Don't hack module unless you are providing patch/enhancement.

You should not need to remove phone.xx.inc files, just disable country validation in the field setting.
API.php file is the documentation, not the real code.

To have your own formatting, just override the theme_cck_phone_formatter_global_phone_number()/theme_cck_phone_formatter_local_phone_number in your theme template.php
i.e.
- Copy the whole theme_cck_phone_formatter_global_phone_number() code
- rename it yourtheme_cck_phone_formatter_global_phone_number()
- do whatever you want with the formatting

adam_b’s picture

Got it - thanks very much.

adam_b’s picture

Status: Fixed » Active

Sorry, next question.

This is working great in the node display but in a view I'm still getting the default spacing of the local number despite disabling country validation.

I tried using the Rewrite Results function but although [field_phone_reservations-number] is fine, [field_phone_reservations-country_codes] gives me "gb" rather than "44", for example.

fallenturtle’s picture

Issue summary: View changes

Dumb question: I see that the function to copy into template.php is in cck_phone.module but the formatting code is in phone.us.inc. How do I merge the two in my template.php file?

I'm trying to change
$phone = '(' . $matches[1] . ') ' . $matches[2] . '-' . $matches[3];
to
$phone = $matches[1] . '-' . $matches[2] . '-' . $matches[3];