Sitecore SelectItems在继承的模板上

Bev*_*van 7 sitecore

我试图根据查询将asp:dropdownlist绑定到某些sitecore项目.通过查询,我想返回继承模板"Site Root"的项目.

我用的时候:

Sitecore.Context.Database.SelectItems("/sitecore/content/*[@@templatename='Site Root']");
Run Code Online (Sandbox Code Playgroud)

它仅返回具有"站点根"模板的项目,而不返回继承此模板的模板.

如何获取查询以返回继承此模板的项目?

Mar*_*owe 7

这是一个返回所有继承特定模板的模板的查询.但要小心,因为它不会表现得很好.

/sitecore/templates//*[contains(@__Base template, '<MY TEMPLATE ID>')]
Run Code Online (Sandbox Code Playgroud)

如果性能很重要,那么使用Sitecore ContentSearch查询模板可能会更好.有一个__template计算字段,需要首先激活.有关详细信息,请参见Sitecore-7-Enable-Default-Computed-Index-Fields.


Mar*_*ino 6

您无法查询继承的模板