Droplink Properties

Droplink Properties

Droplink Fields

  • Store field values as GUID
  • There is no web control for use in declarative markup
  • Not supported by FieldRenderer.Render() method or FieldRenderer control
  • Supported by Sitecore.Data.Fields.ReferenceField class in Sitecore API
  • Support use of Sitecore Query to filter on source property
  • Does not natively support displaying field values in the Page Editor

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Context
  • Sitecore.Data.Database
  • Sitecore.Data.Fields.ReferenceField
  • Sitecore.Data.Items.Item
  • Sitecore.MainUtil

Droplink Properties C# Web Control Code

//get Link Fields metadata item from context database using item guid
Sitecore.Data.Database db = Sitecore.Context.Database;
Sitecore.Data.Items.Item item = db.GetItem("{E3B7CC3C-8C55-4401-A3C9-0FEA9CDA3E9C}");
if (item == null) return;
Sitecore.Data.Fields.ReferenceField droplinkFld = item.Fields["example droplink"];
if (droplinkFld == null) return;

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("C# Web Control Real-time Output");
output.RenderEndTag();

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
//using : for colon and   for space
output.Write("{0}: {1}", "Item", item.DisplayName);
output.RenderEndTag(); //P

output.Write("Path: " + "<b>" + droplinkFld.Path + "</b><br/>"); 
output.Write("Target ID: " + "<b>" + droplinkFld.TargetID.ToString() + "</b><br/>"); 
output.Write("Target Item Name: " + "<b>" + droplinkFld.TargetItem.Name + "</b><br/>"); 
output.Write("Can Read? " + "<b>" + droplinkFld.InnerField.CanRead.ToString() + "</b><br/>"); 
output.Write("Can Write? " + "<b>" + droplinkFld.InnerField.CanWrite.ToString() + "</b><br/>"); 
output.Write("Contains Standard Value? " + "<b>" + droplinkFld.InnerField.ContainsStandardValue.ToString() + "</b><br/>"); 
output.Write("Definition: " + "<b>" + droplinkFld.InnerField.Definition.Name + "</b><br/>"); 
output.Write("Description: " + "<b>" + droplinkFld.InnerField.Description + "</b><br/>"); 
output.Write("Display Name: " + "<b>" + droplinkFld.InnerField.DisplayName + "</b><br/>"); 
output.Write("Has Blob Stream? " + "<b>" + droplinkFld.InnerField.HasBlobStream.ToString() + "</b><br/>"); 
output.Write("Has Value? " + "<b>" + droplinkFld.InnerField.HasValue.ToString() + "</b><br/>"); 
output.Write("ID: " + "<b>" + droplinkFld.InnerField.ID.ToString() + "</b><br/>"); 
output.Write("Contains Inherited Value? " + "<b>" + droplinkFld.InnerField.InheritedValue + "</b><br/>"); 
output.Write("Is Blob Field? " + "<b>" + droplinkFld.InnerField.IsBlobField.ToString() + "</b><br/>"); 
output.Write("Has Been Modified? " + "<b>" + droplinkFld.InnerField.IsModified.ToString() + "</b><br/>"); 
output.Write("Key: " + "<b>" + droplinkFld.InnerField.Key + "</b><br/>"); 
output.Write("Language: " + "<b>" + droplinkFld.InnerField.Language.Name + "</b><br/>"); 
output.Write("Name: " + "<b>" + droplinkFld.InnerField.Name + "</b><br/>"); 
output.Write("Reset Blank On? " + "<b>" + droplinkFld.InnerField.ResetBlank.ToString() + "</b><br/>"); 
output.Write("Section Name: " + "<b>" + droplinkFld.InnerField.Section + "</b><br/>"); 
output.Write("Sort Order: " + "<b>" + droplinkFld.InnerField.Sortorder.ToString() + "</b><br/>"); 
output.Write("Shared? " + "<b>" + droplinkFld.InnerField.Shared.ToString() + "</b><br/>"); 
output.Write("Source: " + "<b>" + droplinkFld.InnerField.Source + "</b><br/>"); 
output.Write("Title: " + "<b>" + droplinkFld.InnerField.Title + "</b><br/>"); 
output.Write("Tooltip: " + "<b>" + droplinkFld.InnerField.ToolTip + "</b><br/>"); 
output.Write("Translatable? " + "<b>" + droplinkFld.InnerField.Translatable.ToString() + "</b><br/>"); 
output.Write("Type: " + "<b>" + droplinkFld.InnerField.Type + "</b><br/>"); 
output.Write("Type Key: " + "<b>" + droplinkFld.InnerField.TypeKey + "</b><br/>"); 
output.Write("Unversioned? " + "<b>" + droplinkFld.InnerField.Unversioned.ToString() + "</b><br/>"); 
output.Write("Validation Regex: " + "<b>" + droplinkFld.InnerField.Validation + "</b><br/>"); 
output.Write("Validation Message: " + "<b>" + droplinkFld.InnerField.ValidationText + "</b><br/>"); 
output.Write("Value: " + "<b>" + droplinkFld.InnerField.Value + "</b>");

output.RenderEndTag(); //Div


Droplink Properties C# Web Control Output

Item: Link Fields

Path: {F01CA6B2-E36D-4AF0-84F2-E533F0C6E3B1}
Target ID: {F01CA6B2-E36D-4AF0-84F2-E533F0C6E3B1}
Target Item Name: ContextDevice
Can Read? True
Can Write? True
Contains Standard Value? True
Definition: Example Droplink
Description: 
Display Name: Example Droplink
Has Blob Stream? False
Has Value? False
ID: {8662E405-E174-40DB-8F48-CD4656A27DA1}
Contains Inherited Value? {F01CA6B2-E36D-4AF0-84F2-E533F0C6E3B1}
Is Blob Field? False
Has Been Modified? False
Key: example droplink
Language: en
Name: Example Droplink
Reset Blank On? False
Section Name: Link Fields
Sort Order: 100
Shared? False
Source: /sitecore/content/home/developers/devices
Title: 
Tooltip: 
Translatable? False
Type: Droplink
Type Key: droplink
Unversioned? False
Validation Regex: 
Validation Message: 
Value: {F01CA6B2-E36D-4AF0-84F2-E533F0C6E3B1}