Display CMS usage on ContentHub’s asset details page

In the previous post, we have set up an index with computed field allowing us to query Sitecore items by referenced assetId. We can now use this to build a nice widget on Contenthub’s asset details page:

Widget that displays all Sitecore items referencing this asset

The Widget

Let’s start with ContentHub. Go To Manage > Pages and search for the “Asset Details” page. Add a new external component to one of the columns:

Custom external component on Asset details page

Add the following to the Template tab:

And this to the Code Tab:

You should now see a “Show usage” button on the asset details page.

The API controller

To make the button work, we’ll need to implement an API controller on the Sitecore Management instance.

We also need two settings in config:

The controller can be called as follows:

https://my-sc-instance/api/ContentHubAssetUsage/GetUsages?assetId=<assetId>

Assuming you already have an api route set up and controllers registered with DI. Read for details here and here if not.

Conclusion

Using an API controller on your management instance in conjuction with a widget on the asset details page, you can display detailed usage of an asset to content authors.

Series Navigation<< Keeping track of ContentHub assets used in Sitecore XM

Leave a Reply

Your email address will not be published. Required fields are marked *