If you use the Droplink field type, you can specify the contents of the list by setting the source property with a sitecore fastquery. The query points to an item whose children are used to populate the list. More specifically, the item.Name is used as the header value and the item.ID is used as the value. This is all fine and well until you want things in the list that aren’t possible due to necessary naming restrictions of Sitecore items.
First, make a copy of the Droplink field type item in the Core DB (/sitecore/system/Field types/List Types/Droplist) and name it “LookupDroplink”
Create the Config for custom custom field like below
<?xml version="1.0" encoding="utf-8"?> <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/"> <sitecore> <controlSources> <source mode="on" namespace="Sitecore.Scientist.Fields" assembly="Sitecore.Scientist" prefix="custom" /> </controlSources> </sitecore> </configuration>
Create the custom class for LookupDroplink.cs
using Sitecore; using Sitecore.Data.Fields; using Sitecore.Data.Items; using Sitecore.Diagnostics; using Sitecore.Shell.Applications.ContentEditor; using System; using System.Collections.Specialized; namespace Sitecore.Scientist.Fields { public class LookupDroplink : LookupEx { private NameValueCollection FieldTypeParameters { get { Item fieldTypeItem = FieldTypeManager.GetFieldTypeItem("LookupDroplink"); return StringUtil.ParseNameValueCollection(fieldTypeItem["Parameters"], '&', '='); } } private string GetFieldNameFromTypeParameters { get { string result = string.Empty; try { result = FieldTypeParameters["FieldName"]; } catch { } return result; } } protected override void OnLoad(EventArgs e) { Assert.ArgumentNotNull(e, "e"); base.OnLoad(e); this.FieldName = this.GetFieldNameFromTypeParameters; } } }
Thanks you for visiting my blog . Happy Coding.