Skip to main content
January 10, 2017

Add a link to call by skype in Drupal 8

by Richard Papp

Websites can use protocol handlers to provide a convenient way for users to open default applications directly from a web page. A common example is a mailto: link for sending an email:

<a href="mailto:info@example.com">info@example.com</a>

When the link is activated, the browser should launch the default email application.

This is becoming even more popular with the proliferation of touch devices like smartphones and tablets. Instead of typing e.g. a long phone number from a web page, the user can call that number by simply clicking on it:

<a href="tel:+1234567890">+1 234 567 890</a>

Drupal limits the allowed protocols. If you use a text filter that strips certain HTML tags, protocols that are not allowed get filtered out. There is no administration page in Drupal core where you could add more protocols to the list.

In Drupal 7 the contributed module Filter allowed protocols provides such an administration page. Or you can add protocols directly in the file /sites/default/settings.php:

<?php

$conf['filter_allowed_protocols'] = array('ftp', 'http', ...);

In Drupal 8 you can add protocols by editing the default filter protocols list in the file /sites/default/services.yml:

parameters:
  # Allowed protocols for URL generation.
  filter_protocols:
    - http
    - https
    - ftp
    - news
    - nntp
    - tel
    - telnet
    - mailto
    - irc
    - ssh
    - sftp
    - webcal
    - rtsp
    - skype

This allows to create a link that visitors can click on to call a skype user (replace the text in brackets with a valid skype user name):

<a href="skype:<username>?call">Skype user name</a>

Tags

Tools

Comments

Add new comment

Klartext

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHA