I am working on Helix based project. I've already implemented Foundation.Indexing project and also I've implemented news search and blog search based on Foundation.Indexing. Now I am working on site content search. I have a small specific in this easy functionality. I need to render search result text depend on item result template.

something like

if (itemResult.TemplateId == NewsTemplateId) 
{ then render "Hello this is news" }
else if (itemResult.TemplateId == BlogTemplateId)
{ then render "Hello this is blog" }
{ render item["BodyText"] }

Following Helix principles: references between features are not allowed.

How I can handle without breaking the principles?

3 Answers 3


I don't see anything wrong with having your Template references in the Foundation Indexing or Foundation Search project. That way your Feature project is not referencing other Feature projects.


You will need to either build this search functionality at the project level, thus being able to see all the feature templates. Or you can move the field you want to search, like Title or Abstract, to the foundation level and search on those fields.

I have searchable fields in a new Foundation.Taxonomy project and then filter my pages on that taxonomy fields.


Actually you are breaking a more important principle of not hard-coding stuff.

It can be easily fixed by adding a new template called i.e. SearchPreviewable with the field Preview Text and inherit your news/blog/etc templates from the SearchPreviewable template.

Then you will only need to do something like this in your code:

 render item["Preview Text"]

Without any template comparison needed.

In case you still want to use the "BodyText" in some cases, you should leave only one comparison statement:

if (itemResult.TemplateId == SearchPreviewableTemplateId) 
{ then render item["Preview Text"] }
{ render item["BodyText"] }
  • Where I should put SearchPreviewable template? should it be feature or foundation?
    – Vlad
    Nov 21, 2016 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.