Use the Sitecore Content Tagging framework in your custom solution

Current version: 10.2

The Sitecore Content Tagging feature provides a generic framework with a set of abstractions that allows you to create a custom implementation for any part of the tagging process. The default implementation enables Sitecore to tag Sitecore items based on the content of each item. The Tag commands on the ribbon in the Content Editor and the Experience Editor integrate the feature into the Sitecore user interface (UI).

To integrate the Sitecore Content Tagging framework into your custom solution, you can use the default Sitecore Content Tagging implementation, or you can build custom providers to implement a custom tagging flow.

To use the default content tagging implementation for Sitecore items in your custom solution:

  1. Get the ContentTaggingRunner and MessageBusFactory  services as follows:

    RequestResponse
    var ContentTaggingRunner = ServiceLocator.ServiceProvider.GetService<IContentTaggingRunner>();
    var MessageBusFactory = ServiceLocator.ServiceProvider.GetService<IMessageBusFactory>();
  2. Create a message bus. The UI can communicate with the process through the message bus. You must also implement a custom message handler.

    RequestResponse
    var messageBus = MessageBusFactory.Create();
    var messageHandler = new CustomMessageHandler();
    messageBus.Subscribe(messageHandler);
  3. Pass the content item and message bus instance to the runner.

    RequestResponse
    ContentTaggingRunner.Run(item, messageBus);

Do you have some feedback for us?

If you have suggestions for improving this article,