开发者

Sitecore SelectItems on Inherited Template

开发者 https://www.devze.com 2023-02-19 22:57 出处:网络
I am trying to bind a asp:dropdow开发者_StackOverflow社区nlist to a some sitecore items based on a query. With the query I want to return items that inherhit the template \'Site Root\'.

I am trying to bind a asp:dropdow开发者_StackOverflow社区nlist to a some sitecore items based on a query. With the query I want to return items that inherhit the template 'Site Root'.

When I use:

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

It only returns items that have the template of 'Site Root', not the templates that inherit this template.

How do I get a query to return items that inherit this template?


Here's a query that returns all templates inheriting a specific template. But be careful as it will not perform very well.

/sitecore/templates//*[contains(@__Base template, '<MY TEMPLATE ID>')]

If performance matters, you'd probably be better off using Sitecore ContentSearch to query the templates. There is a __template computed field for that which needs to be activated first though. See Sitecore-7-Enable-Default-Computed-Index-Fields for details.


You can't query on an inherited template

0

精彩评论

暂无评论...
验证码 换一张
取 消