Making Relations Clickable: A Guide for Enhancing Content Hub Search Results

Content Insights Logo

Today I came across a rather interesting question on the #content-hub Slack channel of Sitecore. Here is where Koen Heye asked if it is possible to link to a relation of an entity in a search result. Before I dive into the answer, I always want to make sure that I fully understand the question before making assumptions about what someone is trying to achieve. If we move into an actual example, what he was asking was the following. When you have a search page, for example, the Assets (overview) page, it shows M.Asset entities. The M.Asset entity definition also has a relation with the M.Collection entity definition. On the Assets page, you want to show this relation as well on an M.Asset entity. You could do this by opening the Assets page and editing the Search component on the Output tab.

On the Output tab, you can select which view you want to change, for instance, the Grid view. Scroll down a bit until the Fields section shows. Add a new field by hitting the +-button. Make the following changes: 

  • Type: Relation
  • Field: Collections
It should look like this:
Assets Search configuration


Hit the Save button and hit the Save button again at the top or bottom of the page. This will make sure that the component itself is saved as well. Otherwise, the change will not show. When we reload our Assets page we see the newly added relation as badges on the screen. However, we want to make these badges clickable and reference them to the Collections detail page.

Updated Assets page

Unfortunately, the relation isn't clickable if you're on a lower Content Hub version than 4.2.28. Since then Sitecore fixed an issue with the relation field. See the documentation for information. But luckily due to the whole Content Hub being a SaaS product, you should be on a higher level by now. In order to make it clickable you need to make the following changes on the Search component Output tab:
  • Display format: Relation
  • Detail Page Name: CollectionDetail
Don't forget to hit Save twice, one for the Field and one for the Component. No refresh your Assets page. A voila, your relation with Collections is now clickable!

What if I'm on an older Content Hub version?
You need to upgrade! We've got a workaround for you as well. On the Search, its configuration scrolls down to Operations. Add the View ancestor detail operation and configure it.

View ancestor details - configuration

There is however one disadvantage of using it this way. It will only show a detail page link to the first relation if any is present. So if you've a one-to-many or many-to-many relationship this will not work out for you. The best solution would be to upgrade the Content Hub instance. The alternative is creating your own Search component with React, but I would highly discourage such a solution. 

Until next time!