Search code examples
templatesindexingsitecore

Sitecore Indexing based off of base template


I am making a custom index but I need it to only index items that have a certain base template or has a certain template name.
I added the base template ID to "include hint="list:AddIncludedTemplate"" but that only uses exact template ID matching and it doesn't allow template names.
I am guessing I need to override something but not sure where to start. This is on Sitecore 8.2.


Solution

  • You can find what you need here: https://ggullentops.blogspot.be/2016/02/custom-indexes-in-sitecore-habitat.html

    For the included templates in the document options I was searching for another solution so I decided to throw my question on the Sitecore Slack Helix/Habitat channel and ended up in a discussion with Thomas Eldblom and Sitecore junkie Mike Reynolds. Thomas came up with the idea to hook into the index process to enable it to include base templates and Mike kept pushing me to do it and so.. I wrote an extension to configure your index based on base templates.

    It's custom code that allows you to define this in your index config:

    <include hint="list:AddIncludedBaseTemplate">
        <BaseTemplate1>{...}</BaseTemplate1>
    </include>