Get Standard Fields

Get Standard Fields

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Collections.FieldCollection
  • Sitecore.Context
  • Sitecore.Data.Fields.Field
  • Sitecore.Data.Items.Item

Standard Fields C# Web Control Code

Sitecore.Data.Items.Item item = this.GetItem();
if (item == null) return;

Sitecore.Context.Item.Fields.ReadAll();
Sitecore.Collections.FieldCollection fields = item.Fields;
if (fields == 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

foreach (Sitecore.Data.Fields.Field field in fields)
{
//only include standard fields
if (field.Name.StartsWith("__"))
{
output.Write("{0}&#58;&#160;{1}", field.Name, "<b>" + field.Value + "</b><br/>");
}
}
 
output.RenderEndTag(); //Div


Standard Fields C# Web Control Output

__Archive Version date: 
__Updated: 20141003T094942:635479265824050939
__Created: 20101228T185211
__Help link: 
__Archive date: 
__Ribbon: 
__Reminder text: 
__Publishing groups: 
__Workflow: 
__Read Only: 
__Created by: sitecore\craig
__Short description: 
__Validator Bar Validation Rules: 
__Lock: 
__Hidden: 
__Workflow Validation Rules: 
__Masters: 
__Long description: 
__Suppressed Validation Rules: 
__Controller: 
__Style: 
__Renderings: 
__Sortorder: 100
__Renderers: 
__Thumbnail: 
__Display name: Get Standard Fields
__Default workflow: {A958495A-A8B3-4570-85B4-EE2E4CCF9C71}
__Valid to: 
__Unpublish: 
__Tracking: 
__Page Level Test Set Definition: 
__Publish: 
__Standard values: 
__Editor: 
__Revision: d901b64f-475e-4f0c-8c08-4c920091432d
__Skin: 
__Reminder date: 
__Validate Button Validation Rules: 
__Source: 
__Preview: 
__Icon: 
__Owner: 
__Editors: 
__Quick Action Bar Validation Rules: 
__Hide version: 
__Never publish: 
__Insert Rules: 
__Valid from: 
__Controller Action: 
__Workflow state: 
__Security: 
__Reminder recipients: 
__Context Menu: 
__Presets: 
__Updated by: extranet\Anonymous
__Originator: 
__Subitems Sorting: