Home » Content Editor » Add a New Sitecore Link Field Type Without Writing Any Custom Code

Add a New Sitecore Link Field Type Without Writing Any Custom Code

Sitecore Technology MVP 2016
Sitecore MVP 2015
Sitecore MVP 2014

Enter your email address to follow this blog and receive notifications of new posts by email.

I’m sure others have blogged about doing something similar to the following — I probably have also blogged about this more than once but cannot remember everything I’ve blogged about given that I have a huge number of blog posts — but I figure this will be helpful to folks new to Sitecore or those who have seen this before but need some reminding.

The other day, I had to create a new Link field type that only gives content authors/editors the ability to insert links to Items within the Media Library. The following steps are what I used to make this happen. I didn’t need to write any custom code, and this would also work for other solutions similar to this though keep in mind that this solution will only work within the Content Editor — to make this work in the Experience Editor, you will have to write some custom code which I might show in a future blog post.

Step 1: Duplicate an existing field type.

Here I am duplicating ‘/sitecore/system/Field types/Link Types/General Link’ in the Core database:

step-one

Step 2: Delete button items that you don’t need.

I’ve deleted all buttons that are not related to Media library items, and also preserved the Follow and Clear button items:

step-two

Step 3: Add a new field using the new type you have created in step 1.

Just add the new field on a template:

step-three

Step 4: Go to an item using the template from step 3.

As you can see, only the buttons that you preserved from step 2 are there:

step-four

Step 5: Click one of the buttons that you preserved from step 2.

Here, I clicked the ‘Insert media link’ button:

step-five

After clicking the ‘Insert’ button from the dialog in step 5, I see that a Media Library Item link was set within this new field:

step-six

Raw values:

media-link-raw-values

If you have any comments/thoughts/suggestions on this, please share in a comment.


1 Comment

  1. Yogesh Patel says:

    Nice Trick Mike.. never thought media link can be this much simplified.. 🙂

Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.