1

I would like to be able to add the file:// protocol to the list of filter_protocols so that we can add links to shared company files on a mapped drive from within our intranet website, but I'm not sure how to do this. Right now, it is apparently not included, according to Link Module Overview. Is there a way to manually configure this list in order to add file://?

1 Answer 1

4

You can override that in a container services file.

For example, create/edit /sites/default/services.yml, and add/alter the following lines:

parameters:
  filter_protocols:
    - http
    - https
    - ftp
    - news
    - nntp
    - tel
    - telnet
    - mailto
    - irc
    - ssh
    - sftp
    - webcal
    - rtsp
    - file

and make sure you have this line uncommented/added to settings.php:

$settings['container_yamls'][] = $app_root . '/' . $site_path . '/services.yml';
8
  • Hmm. I tried that and it unfortunately did not work for me. In my sites/default/ directory i have two files besides my newly created services.yml file and the preexisting settings.php file: default.services.yml and default.settings.php. I edited both of these default files in the same way you described above for the non-default settings.php and services.yml. When I click on my html link on my web-page, <a href="file://C:/Users/AdamNoack/Desktop/test1.docx">local file</a> nothing happens. I have tried many different variations of this a tag and nothing seems to work.
    – Adam Noack
    Commented Jun 18, 2018 at 15:51
  • 1
    Is it on a local domain? Some browser security policies disallow embed/redirect to file:// protocol for local domains. If that's the problem it's not one Drupal can help to solve; Drupal's only involvement is rendering the file:/// URL in the first place
    – Clive
    Commented Jun 18, 2018 at 15:59
  • 1
    Oh you're right! It now at least works in IE. Doesn't work in chrome though. Thank you!
    – Adam Noack
    Commented Jun 18, 2018 at 16:08
  • 2
    It works in chrome with this chrome extension: enable local file links
    – Adam Noack
    Commented Jun 18, 2018 at 18:32
  • +1 this is an awesome answer. For my project I needed to have WhatsApp symbol as a menu link within a standard Drupal menu. fontawesome_menu_icons solved the visual - provided a WhatsApp symbol, along with menu_link_attributes for styling. 1 / 2 Commented Dec 15, 2020 at 0:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.