Sitecore: Creating Fieldtype External link only

During an Sitecore .Net development training I was ask if there is a fieldtype for an external link. The answer (of course) is; “Yes, general link”. With general link you can create a external link and many other types of links.  But what if you want to create a field in which the business users can only add an external link? You can easily create this with Sitecore (without any coding).

 

Create the External Link only Fieldtype

Fieldtypes are defined in the Core database. Switch to the core database and open the content editor and duplicate the /sitecore/system/Field types/Link Types/General Link item and call the item External Link.

Remove the unused link options

Underneath the newly created External Link item there is a folder called menu. Remove all items in the Menu folder except External Link, Clear and Follow.

 

Test the External Link Fieldtype

Switch back to the Master database and add a External Link field the to a template. Open an Item based on the template and you will see the newly created External Link field.

 


That’s it, we have created a new Fieldtype that only accepts External links.

2 Replies to “Sitecore: Creating Fieldtype External link only”

  1. Nice explanation Pieter! But don’t you also need to update the renderField pipeline to handle this type of field (basically, duplicate the code in the GetLinkFieldValue processor and change the field type name…hmm, maybe these processors should accept an optional list of type names using the configuration factory)? But since this specific field type never stores an internal link, you don’t have to update /App_Config/FieldTypes.config to enable link tracking for this new field type.

    1. John, thanks for your comment. This blog post is based on series of posts I intended to write. In that blogpost series I’m going to add an external DMS tracked link fieldtype based on the general link. So you can choose if you want to track instead of tracking all links:
      Measure Outgoing Links with DMS

      I´m still trying to finish the POC and documenting my steps, but in the meanwhile wrote this small post. Let me check the steps again, I thought it worked.

      To be continued….

Leave a Reply

Your email address will not be published.