Answer the question
In order to leave comments, you need to log in
How to display phone number via Html helper?
Hello.
--
The situation is such that I was looking for a way to make the phone on the site clickable. That is, not just a link, but a function call. tel:
Very useful for mobility, when you click on such a number with your finger on the phone, the phone number is dialed. That is, you do not need to copy, paste, retype from the browser, but simply clicked and called. So, in Yii2 there is a solution with email:
we get:'[email protected]')
= Html::mailto(
<a href="mailto:[email protected]">[email protected]</a>
<?=Html::a();?>
<?=Html::phone('+7 (999) 00-00-000', ['class' => 'phone']);?>
<a class="phone" href="tel:+7 (999) 00-00-000">+7 (999) 00-00-000</a>
...
public static function phone($phone, $options = [])
{
$options['href'] = 'tel:'.$phone;
if (!isset($options['class'])) {
$options['class'] = '';
}
return static::tag('a', $phone, $options);
}
...
Answer the question
In order to leave comments, you need to log in
Swiper is ideal https://github.com/nolimits4web/Swiper/
set all slides to opcaity: .5; and active slide opacity: 1
use text part as thumb:
https://github.com/nolimits4web/Swiper/blob/master...
The easiest option is to create your own class inherited from Html and use it throughout the project:
<?php
namespace app\helpers;
class Html extends \yii\helpers\Html
{
public static function phone($phone, $options = [])
{
$options['href'] = 'tel:'.$phone;
if (!isset($options['class'])) {
$options['class'] = '';
}
return static::tag('a', $phone, $options);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question