3

We have requirement where if a Content Item is Tagged with “Espresso” and “Cappuccino” then this content Item will automatically be populated in the page when searched for both types of tags “Espresso” and “Coffee” where Coffee is parent Tag. So my question is

  1. How do I do this in CMS when if a Content Author when selects one type of tag(Cappuccino) parent Tag(Coffee) would be automatically applied

  2. To avoid performance hit how should we do this in CD we are using Solr

Regards SA

1

The approach I have taken in the past to do the least index customization was to make sure my call from the code to the ContentSearch API passed in all options. I would make sure my call included both the selected parent as well as possible children.

When search code would execute, I would try to find all the ones the user didn't select that would also apply. So, if the user picked "Coffee" and "Espresso" I would then try to make sure I passed "Coffee", "Espresso", and "Cappucino" into the search query.

The general approach would be this (pseudo-code, not real C#):

List<Item> GetTags(List<Tag> tags){
  List<Tag> allTags = copy of tags;

  //Get the children of the selected tag (and their children)
  foreach(tag in tags){
     if(tag has children){
       allTags.Add(GetTags(tag.children))
     }
  }

  return allTags;
}

The above was for illustration purposes of a brute-force method. In actual implementation, you would probably execute a content search for all tags that had the selected tag as a parent in the index so that you could quickly get all of the tags in a sub-tree of your taxonomy. You would then pass this tag list as the actual filters for your search instead of the ones selected by the user.

If you are already loading all of the taxonomy into memory for display on the screen, you might already have an in-memory object you could search to find the children as well.

0

Espresso or Cappuccino are actually the types of coffee. You can use Sitecore rules for personalization. You can create a rule and check if current item's tag field has the value of type coffee(like for “Espresso” and “Cappuccino”) then show the rendering else hide. You should refer to rule based personlization.

3
  • Espresso” and “Cappuccino" are just two examples we have thousands of other types of similar cards also are you are trying say that i create rule with always check what is parent type and then display the content . – user2332873 Sep 5 '17 at 10:43
  • My Questions was more on how do i handle this on CMS – user2332873 Sep 5 '17 at 10:44
  • Rule should be generic. Coffee is a Category and Espresso is a keyword. Similarly there can be other combination of Category and Keywords. Now you can create rule which will identify the category of a keyword i.e a tagged item and then accordingly you can personalize the rendering for Category equals to or not equal to category then show/Hide or use different datasource. – AlokBhatt Sep 5 '17 at 11:22

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.