通过创建FieldID属性,您应该可以访问控件中的Field ID。这应该等同于定义该字段的模板字段项目的ID。因此,你可以通过
var fieldItem = Sitecore.Context.ContentDatabase.GetItem(this.FieldID);
var fieldName = fieldItem.Name;
获取字段的名称Sitecore的可以在你的控制设置可以在Sitecore.Shell.Applications.ContentEditor.EditorFormatter.SetProperties
找到特性的完整列表。
ReflectionUtil.SetProperty(editor, "ID", field.ControlID);
ReflectionUtil.SetProperty(editor, "ItemID", field.ItemField.Item.ID.ToString());
ReflectionUtil.SetProperty(editor, "ItemVersion", field.ItemField.Item.Version.ToString());
ReflectionUtil.SetProperty(editor, "ItemLanguage", field.ItemField.Item.Language.ToString());
ReflectionUtil.SetProperty(editor, "FieldID", field.ItemField.ID.ToString());
ReflectionUtil.SetProperty(editor, "Source", field.ItemField.Source);
ReflectionUtil.SetProperty(editor, "ReadOnly", readOnly);
ReflectionUtil.SetProperty(editor, "Disabled", readOnly);
你想用自定义字段来做什么,需要你知道字段名称? – techphoria414
我的字段通过搜索Sitecore系统索引中的相似命名项目来检查可能的重复项目标题。我需要知道字段名称才能构建Lucene查询。 –
当你在控件中使用jquery操作(在我的情况下隐藏和取消隐藏)和一个项目中的多个字段时 - 当你不考虑名称时隐藏和取消隐藏会影响所有字段,这也很有用。 –