R
R
RushV2019-04-19 14:53:08
MODX
RushV, 2019-04-19 14:53:08

How to correctly implement the output of phones in ModX?

Hello!
How to correctly implement the output of phones?
Through additional fields so that the number is wrapped in a span tag.
Example:

<span>номер телефона 1</span>
<span>номер телефона 2</span>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Froggyweb, 2019-04-19
@Froggyweb

Client config - extension

E
Evgeny Shvelev, 2019-04-25
@mr-mit

Hey! you can use snippet

<?php
$id = (isset($id)) ? $id : '';
$tvname = (isset($tvname)) ? $tvname : '';
$resource = $modx->getObject('modResource', $id); 
$phone = $resource->getTVValue($tvname); 
$phone_edit = preg_replace("/[^0-9]/", '', $phone); 
echo '<span><a href="tel:+'.$phone_edit.'">'.$phone."</a></span>";

Output like this where id is the resource number of the tv phone tv name is the name of the tv phone. in the snippet in the echo line you can set the required output template
If you don’t need to make the phone clickable, you can remove the tag and

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question