0

In my website, I'm creating a dynamic external link to open email from Outlook using outlook:{Entry ID} link. It should be like:

outlook:000000006CD8BD6F1761654D9AD70F841783C591070062F134BA8C073B4296C8467090C20CF200000089D837000010EBA743D9305C4891225FE3E347AE1800003B82DF840000

I tried to use:

  1. "Rewrite the output of this field": <a href="outlook:[guid]">open outlook</a>

AND/OR

  1. Output this field as a link, with link path: outlook:[guid] with options: "Use absolute path" and "External server URL" enabled.

The problem is no matter I use in Views field rewrite, the anchor's href outlook: replaced with http://localhost/ or http://localhost:8080/pms/outlook%3A

What do I need to do to generate the link correctly in format outlook:[guid]?

2
  • What version of Drupal?
    – Clive
    Nov 22, 2018 at 15:26
  • @Clive Drupal 7.61 Nov 22, 2018 at 16:24

2 Answers 2

0

The problem is that the URL code in Drupal doesn't recognise your "outlook:" prefix, and so is trying to make it a valid version of a protocol it does know. Option (2) explicitly invokes the URL code, so it is not surprising that it changes the href.

I am slightly surprised that the rewrite version didn't work, and can only assume you had other options set in the View which caused this -- or that the page was cached.

If you cannot get the rewrite to work, I suggest you override the field with a view-specific field template (see "theme information" in the theme config), in which you can do whatever you wish.

2
  • No cache I'm sure. What do you mean by "override the field with a view-specific field template", would you please elaborate? Nov 22, 2018 at 18:08
  • Just for reference, to resolve it 1. I created sub-theme, and in the subfolder "templates", 2. I added file "views-view-field--guid.tpl" (the exact name as in my View (Advanced => Theme: Information), 3. edit it to replace <?php print $output; ?> with <?php print '<a href="outlook:' . $output . '">open outlook</a>'; ?> Nov 22, 2018 at 21:09
0

You don't seem to be using a valid protocol allowed in URL but I guess you're building something within a closed context. https://en.wikipedia.org/wiki/URL#Syntax

There are two things to consider here, one is how to control the output of the Drupal field, the other is how to construct a valid HREF.

Drupal Rewrite results

Try the plain Rewrite the output of this field, without the Output as link. Since you're including the anchor code yourself in the Rewrite Text, you don't want Drupal to construct the link. Drupal will probably always assume and use the HTTP protocol, and you want a different protocol.

By setting up the Rewrite this way you won't have to override through views templates.

Construct valid HREF

The outlook: prefix is only a Windows-specific preference for which application to use to open the link, it isn't a URI scheme/protocol. Without a protocol no application knows what to do with the link. You still have to provide either a valid internet link outlook:http://blahblah or a link to a local file outlook:file://blahblah.

Maybe Outlook does some special treatment and will know what to do with the link, I don't have any experience with that, try asking on MS-specific support sites about that part.

Your Answer

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

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