Add Telephone Link to the General Link field type in Sitecore

Posted 02/21/2015 by Akshay Sura

I wanted to extend the General Link field to add a new Menu Item to create a Telephone link. A Telephone link is primarily used to render a telephone number so that it helps the mobile user to dial out the phone number.

e.g.: <a title=”Call Customer Service at 1-222-333-4455″ class=”phone” href=”tel:12223334455″>Call Customer Service</a>

In order to achieve this functionality we need to do the following:

1. Go to the Core database, and add a menu item under /sitecore/system/Field types/Link Types/General Link/Menu. Name it Telephone.

2. Set the Display Name field of this newly created Menu Item to Insert Telephone Link

3. Set the Message field to contentlink:telephonelink(id=$Target)

Menu Link

4. Create a class called TelephoneLink to handle the link message. The above entry in the Message Field should match the switch case statement.

5. Click on General Link and modify the Control property to content:TelephoneLink

General Link

6. Create a config patch file to register the control source.

7. Create a new folder called TelephoneLink under /sitecore/shell/Applications/Dialogs 

Explorer

8. Create an xml file called TelephoneLink.xml

9. Create a class called TelephoneLinkForm to act as the code behind for TelephoneLink.xml

10. We need to handle the Rendering of the Telephone Link, so create processor RenderPhoneLink 

11. Add to config patch file to run the RenderPhoneLink processor right before the GetLinkFieldValue processor

Now all you have to do is to keep using the sc fields such as <sc:Link and the field value will be rendered properly.

Final

If you have any questions or comments please get in touch with me. Thank you.