V
V
Vasily Vyaznikov2017-08-07 17:49:22
MODX
Vasily Vyaznikov, 2017-08-07 17:49:22

Is it possible with pdoTools to display only numbers from the TV field?

The phone number must be entered correctly.
Now the conclusion is as follows:

<a href="tel:" class="phone header__phone"></a>

The problem is that the field now contains a phone number of the form: 8 (000) 000-00-00 and this line is displayed in the link, which is not correct (w3c validator swears).
Is it somehow possible for pdoTools (or another solution) to leave only numbers out of a string?
PS Now I have written my own snippet that parses the string (but it seems to me that with the help of pdoTools you can solve the problem):

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DarWiM, 2017-08-17
@vyaznikov1991

Fenom in the pdoTools package can do something like this

{5 | resource : 'phone-1' | preg_replace : '[^0-9]' : ''}

F
Froggyweb, 2017-08-07
@Froggyweb

It is worth writing a snippet that works as a modifier, for example, look at how insane dates are filtered

V
Vasily Vyaznikov, 2017-08-07
@vyaznikov1991

Thanks Froggyweb for the idea.
I wrote a simple snippet with a regular expression that leaves only numbers in the string:

<?php
$result = preg_replace('/[^0-9]/', '', $input);;

return $result;

And now I just write:
<a href="tel:" class="phone header__phone"></a>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question