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
精彩评论