불행히도 Adam Najmanowicz's answer에 언급 된 파이프 라인은 Droplink 및 Multilist와 같은 일부 다른 유형에서는 작동하지만 Droptree 필드에서는 파이프 라인이 실행되지 않습니다.
이 깊은에보고 후 나는 아담이 언급 한 바와 같이 Droptree 필드의 소스가 잘못된 상황에 맞는 항목을 사용하고 있음을 발견하지만, 코드는 Droptree 필드 자체에서 온다 : -
Sitecore.Shell.Applications.ContentEditor.Tree, Sitecore.Kernel
활용 Adam의 대답에서 쿼리 문자열 코드, 우리는 '고정'Droptree 사용자 정의 필드를 만들 수 있습니다.이 필드는 일반 Droptree와 거의 같지만 올바른 컨텍스트 항목을 대신 사용합니다. 코드는 일반적인 Tree 컨트롤에서 상속되며 Source 속성이 설정되는 방식 만 변경합니다.
public class QueryableTree : Sitecore.Shell.Applications.ContentEditor.Tree
{
// override the Source property from the base class
public new string Source
{
get
{
return StringUtil.GetString(new string[]
{
base.Source // slightly altered from the original
});
}
set
{
Assert.ArgumentNotNull(value, "value");
if (!value.StartsWith("query:", StringComparison.InvariantCulture))
{
base.Source = value; // slightly altered from the original
return;
}
Item item = Client.ContentDatabase.GetItem(this.ItemID);
// Added code that figures out if we're looking at rendering parameters,
// and if so, figures out what the context item actually is.
string url = WebUtil.GetQueryString();
if (!string.IsNullOrWhiteSpace(url) && url.Contains("hdl"))
{
FieldEditorParameters parameters = FieldEditorOptions.Parse(new UrlString(url)).Parameters;
var currentItemId = parameters["contentitem"];
if (!string.IsNullOrEmpty(currentItemId))
{
Sitecore.Data.ItemUri contentItemUri = new Sitecore.Data.ItemUri(currentItemId);
item = Sitecore.Data.Database.GetItem(contentItemUri);
}
}
if (item == null)
{
return;
}
Item item2 = item.Axes.SelectSingleItem(value.Substring("query:".Length));
if (item2 == null)
{
return;
}
base.Source = item2.ID.ToString(); // slightly altered from the original
}
}
은 위의 코드는 우리가 발견 한 경우 우리는 우리가에있어 그 URL에서 적절한 상황에 맞는 항목을 파악하는 것을 제외하고, 거의 기본 트리 필드에서 Source 속성과 동일 렌더링 매개 변수 대화 상자.
사용자 정의 필드를 만들려면 here과 같이 Web.Config 파일을 편집하면됩니다. 그런 다음 here과 같이 코어 데이터베이스에 사용자 정의 필드를 추가하십시오.
이것은 매개 변수가 이제 해당 소스에 대한 쿼리를 가질 수 있으므로 사용 가능한 항목을 콘텐츠 편집기로 제한 할 수 있음을 의미합니다. (다중 사이트 솔루션에 유용합니다).
데이터 소스를이 필드가있는 "구성"유형의 항목으로 만들면 설명 된대로 쿼리 소스가 포함 된 일반 Droptree 컨트롤을 가질 수 있습니다. 또한 데이터 소스를 고수하고 있기 때문에 컨트롤이 쉽게 개인화되고 다 변수 테스트가 가능합니다. –
개인 설정 및 테스트 작업은 사실이지만이 컨트롤은 이미 컨트롤의 다른 속성으로 DataSource 필드를 사용하고 있습니다. 그래도 선택 가능한 유일한 속성 인 경우 DataSource를 대신 사용할 수 있습니다. –