我已经创建了自定义树视图字段 - 多选树视图。
此字段继承自Sitecore.Shell.Applications.ContentEditor.TreeList并带有重写方法Add():
public class MultiselectTreeList : TreeList
{
protected new virtual void Add()
{
bool alert = true;
if (this.Disabled) return;
string viewStateString = this.GetViewStateString("ID");
var treeviewEx = this.FindControl(viewStateString + "_all") as TreeviewEx;
Assert.IsNotNull(treeviewEx, typeof (DataTreeview));
var listbox = this.FindControl(viewStateString + "_selected") as Listbox;
Assert.IsNotNull(listbox, typeof (Listbox));
if (treeviewEx == null)
{
SheerResponse.Alert("TreeviewEx control not found..", new string[0]);
}
else
{
Item[] selectionItems = treeviewEx.GetSelectedItems();
if (selectionItems == null)
{
SheerResponse.Alert("Select an item in the Content Tree.", new string[0]);
}
else
{
foreach (Item selectionItem in selectionItems)
{
if (this.HasExcludeTemplateForSelection(selectionItem)) return;
if (this.IsDeniedMultipleSelection(selectionItem, listbox))
{
if (alert)
{
SheerResponse.Alert("You cannot select the same item twice.", new string[0]);
alert = false;
}
}
else
{
if (!this.HasIncludeTemplateForSelection(selectionItem)) return;
SheerResponse.Eval("scForm.browser.getControl('" + viewStateString +
"_selected').selectedIndex=-1");
var listItem = new ListItem {ID = GetUniqueID("L")};
Sitecore.Context.ClientPage.AddControl(listbox, listItem);
listItem.Header = this.GetHeaderValue(selectionItem);
listItem.Value = listItem.ID + (object) "|" + selectionItem.ID;
SheerResponse.Refresh(listbox);
SetModified();
}
}
}
}
}
}
我在核心数据库中注册了它:/ sitecore / system / Field types / Custom Types / Multiselect Tree List:fill assembly and Class fields。
添加了多选treelist字段的项目。填充数据。多项选择正常。
但是当我尝试使用Ribbon-> Navigate->链接找到引用时,我看不到对项目的引用(也错过了主数据库中的链接表中的TargetItemId)。
当我将其更改为Sitecore Treeview字段时 - 一切正常。
据我所知,抓取工具不会将我的字段和未添加到数据库的链接编入索引。
任何想法如何解决这个问题?
答案 0 :(得分:3)
在App_Config \ FieldTypes.config中注册您的字段类型。完成后,将来对该字段的写入将包含在LinkDatabase中。
答案 1 :(得分:0)
尝试将其添加到索引配置中:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:x="http://www.sitecore.net/xmlconfig/">
<sitecore>
<fieldTypes>
<fieldType name="Multiselect Treelist" type="Sitecore.Data.Fields.MultilistField,Sitecore.Kernel" />
</fieldTypes>
<contentSearch>
<indexConfigurations>
<defaultLuceneIndexConfiguration>
<fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch">
<fieldTypes hint="raw:AddFieldByFieldTypeName">
<fieldType fieldTypeName="multiselect treelist" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
</fieldTypes>
</fieldMap>
<fieldReaders type="Sitecore.ContentSearch.FieldReaders.FieldReaderMap, Sitecore.ContentSearch">
<mapFieldByTypeName>
<fieldReader fieldTypeName="multiselect treelist" fieldNameFormat="{0}" fieldReaderType="Sitecore.ContentSearch.FieldReaders.MultiListFieldReader, Sitecore.ContentSearch" />
</mapFieldByTypeName>
</fieldReaders>
</defaultLuceneIndexConfiguration>
</indexConfigurations>
</contentSearch>
</sitecore>
</configuration>