Clean Phone Numbers in TYPO3: Why We Built EXT:phone_number

A small Fluid ViewHelper that turns messy input into consistent, standardized output

| David Steeb
A purple graphic featuring a smartphone icon with three horizontal bars, surrounded by illustrations of vintage telephones.

TYPO3’s link wizard has had a dedicated Phone link type for a while now, and used consistently it’s genuinely useful: editors store phone numbers as proper tel: links, so the linking itself is correct and reliable. You’ve done the hard part—getting everyone to enter their numbers the right way.

The catch is the frontend. Once the number is stored correctly, you still have to decide how it should actually look on the page—full international form, national form, following DIN 5008—and TYPO3 doesn’t format it for you. The same stored number might need to appear one way in your imprint and another way in the footer.

This is where our little extension phone_number comes in. It does one thing: it takes the phone number an editor has already stored—as a tel: link or a raw string—and formats it for output in the frontend. In this post I’ll explain the problem it solves and how to use it.

Why the Output Format Matters

What visitors actually read is the number printed on the page, and that’s where consistency counts. A number shown three different ways across three pages chips away at the polish of an otherwise clean site.

International visitors expect a predictable format, and in Germany the DIN 5008 standard sets clear rules for how a number should be written. Depending on the context you might want the full international form (+49 711 3400810) in your imprint and the shorter national form (0711 3400810) in a footer—ideally from the exact same stored number, without touching the backend.

Doing that formatting by hand in every template doesn’t scale. Each one ends up with its own little bit of logic, and over time you get exactly the kind of wild growth we try to avoid: many slightly different solutions to the same problem.

Our Solution: A Small ViewHelper Powered by libphonenumber

A stylized smartphone icon with signal bars, set against a purple and orange gradient background.

The idea behind phone_number is deliberately narrow: one Fluid ViewHelper that takes a raw phone number or a tel: URI and formats it into a clean international or national number. One line in your template, consistent output everywhere.

Installation works as usual via Composer:

A stylized smartphone icon with signal bars, set against a purple and orange gradient background.
1
composer req b13/phone-number

Then register the namespace in your Fluid template:

1
2
3
4
5
<html
data-namespace-typo3-fluid="true"
xmlns:phone="http://typo3.org/ns/B13/PhoneNumber/ViewHelpers"
>

From there it’s a one-liner. International format is the default:

1
<phone:format value="tel:+497113400810" />

Output: +49 711 3400810

Need the national format instead? Flip one argument:

1
<phone:format value="tel:+497113400810" national="1" />

Output: 0711 3400810

It’s not limited to German numbers, either. Pass a US number and libphonenumber formats it the American way:

1
<phone:format value="tel:+12125550123" />

Output: +1 212–555–0123

Switch to national=”1” and you get (212) 555–0123—the format US readers expect.

The country comes from the number itself: the +1 tells libphonenumber it’s a US number, so the right format follows automatically—independent of your site’s language. The defaultRegion argument (more on it below) only kicks in for numbers stored without a country code, telling the parser which country to assume.

And if a number is stored as a plain string rather than a tel: link, it normalizes that too:

1
<phone:format value="+49 (0) 711 34008-10" />

Output: +49 711 3400810

This is the case the extension is really built for: a field defined as TCA type=link with allowedTypes=telephone—the Phone link type from the wizard—hands you a tel: URI, and the ViewHelper turns it straight into clean output. The number an editor picks in the backend is the number your visitor sees, cleanly formatted, every time.

The Arguments, at a Glance

The ViewHelper keeps its options short and predictable:

  • value — the phone number or tel: link to format. Required.
  • defaultRegion — the region used to parse numbers that come without a country code. Defaults to DE, and it only matters for those bare numbers—so set it to your company’s home country rather than the site’s language (the English site of a French company still wants FR here).
  • national — format the number in national style (0711 …) instead of international. Defaults to off.

Requirements

EXT:phone_number runs on PHP 8.1 and supports TYPO3 12, 13, and 14. It’s open source under GPL-2.0-or-later, and the number parsing is handled by libphonenumber-for-php-lite—so you get battle-tested formatting rules without pulling in a heavy dependency.

Conclusion

Phone numbers are a small detail, but small details are what make a site feel finished. Instead of formatting them by hand in every template, EXT:phone_number gives you one consistent, reusable way to do it: install the extension, register the namespace, add one ViewHelper, and your numbers just look right.

Documentation and source code are available on GitHub: https://github.com/b13/phone-number

Got a tricky formatting case?

Whether you’re cleaning up phone numbers across a large TYPO3 installation or fine-tuning the details on a single site, we’re happy to help. If you’d like support with EXT:phone_number or your TYPO3 project in general, feel free to get in touch with us.