Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi. Thanks for this module.
I am trying to extend it using a small additional module, to add a whatsapp link.
It should be straightforward, but I seem to be missing something, as site link keeps getting pre-attached to link. i.e
my_site_link/whatsapp://send?text=<raw-encoded-url>&
instead of:
whatsapp://send?text=<raw-encoded-url>&
I am using this in module:
function extra_services_service_links() {
$links = array();
$links['whatsapp'] = array(
'name' => 'Whatsapp',
'description' => t('Share via Whatsapp'),
'link' => 'whatsapp://send?text=<raw-encoded-url>&',
);
return $links;
}
Comments
Comment #1
zeezhao CreditAttribution: zeezhao commentedCan't edit original. Trying to say also tried:
Comment #2
Koen.Pasman CreditAttribution: Koen.Pasman at Aubergine IT commentedI'm running into similar problems. I have tried using the hook_service_links() and hook_service_links_alter() but both get pre-attached or cached or whatever you want to call it.
Comment #3
jlenni CreditAttribution: jlenni commentedSee: https://mikekeran.com/other/adding-custom-mobile-protocols-to-drupal
Comment #4
jlarrubia CreditAttribution: jlarrubia commented#3 Good catch! It worked for me.
Comment #5
Dries ArnoldsThe website from #3 is no longer online. I'm curious what the solution was.
Comment #6
Dries ArnoldsThis is a solution that I found: https://www.drupal.org/project/filter_protocols
Comment #7
jlarrubia CreditAttribution: jlarrubia commentedHi @pixelstyle,
you can do this programatically by extending the variable 'filter_allowed_protocols' with the protocol you need (e.g. whatsapp):
/**
* Adds whatsapp:// protocol to the list of allowed protocols.
*/
function example_update_7001($sandbox) {
// From include/common.inc @ 1336
$protocols = variable_get('filter_allowed_protocols', array('ftp', 'http', 'https', 'irc', 'mailto', 'news', 'nntp', 'rtsp', 'sftp', 'ssh', 'tel', 'telnet', 'webcal'));
$protocols[] = 'whatsapp';
variable_set('filter_allowed_protocols', $protocols);
}
Source: http://drupalsun.com/mikekeran/2013/11/26/adding-custom-mobile-protocols...