Create Custom Definition In Sitecore Content Hub And Display Using OOTB component

In Sitecore Content Hub, definitions are blueprints that structure and classify content entities like assets, contracts, and products. They let you customize metadata, add relationships, properties, and constraints, and either extend built-in definitions (e.g., M.Asset, M.Collection, M.Content) or create new ones based on project needs. This guide explains how to create new definitions and when they’re required

We will see, how one can create its own custom definition in content hub according to business need with an example. Let’s walk through a real-world example of creating a new definition for Marketing Campaigns. In this use case, we will build a custom definition that allows your organization to track marketing campaigns with attributes like CampaignName, StartDate, EndDate, Location, MarketingAssets and CampaignStatusActive

Step 1: Creating New Definition

Log in to your Sitecore Content Hub instance, navigate to Manage, then search for Schema. Click on Schema, and you’ll see an interface similar to this. Next, click on New Definition and name your definition MarketingCampaign.

Creating New Group

Create a new group called "Core Details", where you will add fields such as CampaignName (String), StartDate (DateTime), EndDate (DateTime), and Location (currently set as a String, though it can be created as a Taxonomy). The MarketingAssets field will be a Many-to-Many Relation, and CampaignStatusActive is set as a Boolean.

Click on "Apply Changes" to save the fields in the newly created group.

Creating New Marketing Campaign Page

Create a new page for the entity MarketingCampaigns, along with a subpage named New Marketing Campaign.
































Open MarketingCampaigns page, add a Creation Component and make it visible. Click on the Creation Component, go to General, select Custom for the button, create a translation, and assign a label to the button

On the New Marketing Campaign page, add an Entity Details Component, then click on it and configure it for the MarketingCampaign definition. Under Members, select Core Details, enable the Hide Group Label toggle, and review the other settings in the Settings tab

Go back to the MarketingCampaign page and click on View Page. You should now see the page with the added Creation Component and button. Click on New Marketing Campaign, and a pop-up with the defined properties will open






















I've added a few marketing campaigns. To quickly view all entities created through this definition, navigate to Manage -> Entities. In the Entities section, search for the MarketingCampaign definition. You’ll see all entities created with this definition. To view full entity details, click on View Detail

Step 2: Let's use OOTB search component to display our all entities.

To manage and display the Marketing Campaigns entities, we will use the Search Component. Here's how to set it up:

Navigate to the Manage Section. Select Pages from the dropdown. In the Pages section, choose the page where you want to display the Marketing Campaigns entities. Now use Marketing Campaigns page created earlier.

On the Marketing Campaigns page, locate the Main Zone and click on the + Component button. A pop-up will appear. Select Search Component from the list of available components. Click Add to insert the search component into the page.





































Name the component Search Marketing Campaigns to reflect the purpose.Ensure the Toggle Visible option is enabled to display the component on your page.Click Save to apply the changes.

Configuring the Search Component

Adding the Search Component, we need to configure it to display the Marketing Campaigns based on the Core Details fields we defined earlier.Click on the newly added Search Marketing Campaigns component to open its configuration settings.

Configure search component now.

Set Up Filters:

Navigate to the Filters Tab.Within the System Tab, you can define the type of filters that will be applied to the search results. Select Filter Type and choose options like Definition, Property, Relation, or Selection. For our example, choose Definition and then select MarketingCampaign to filter only those entities created from the Marketing Campaigns definition.

Configuring Functionality

We’ll set up the functionalities to control how users can interact with the search results. Now let's enable Enable Full-Text Search. In the Functionality Tab, you can enable various search features. Enable Full Text Search to allow users to search across all fields of the Marketing Campaign entities.

Configuring Facets and Filters in search component.You can enable Facets to provide filterable categories based on the CampaignName, StartDate, or CampaignStatusActive.

Enable sorting and pagination to help users navigate through large sets of Marketing Campaigns easily in search component.

Add a Refresh Button so users can refresh the search results without reloading the entire page.

Now you can customize the Output too. After setting up filters and functionality, we will configure how the search results are displayed to users.

Choose Display Format:In the Output Tab, define how the results should be displayed.You can choose between a Tabular view (table format) or a Grid view depending on your preference. For a quick overview of multiple campaigns, the Tabular View may be more efficient as it allows you to display details like CampaignName, StartDate, EndDate, and CampaignStatusActive in columns.

Add Operations:You can also add operation like Deleting Entities, allowing users to manage campaigns directly from the search results.






































Save and Finalizing the Search Component: Save the search component now. You should now see the Search Marketing Campaigns component on the page, displaying results based on the MarketingCampaign definition.

We have enable functionality for deleting the entity. You can delete the entities easily.













Thanks for reading this long blog, but I hope, this will give you clear understanding how we create new custom definition in Content Hub and use the OOTB component to show it in our own custom page.

You can check my other blogs too if interested. Blog Website

Comments

Popular posts from this blog

Automate RSS Feed to Sitecore XM Cloud: Logic App, Next.js API & Authoring API Integration

Sitecore XM Cloud Form Integration with Azure Function as Webhook

Sitecore 10.2 Installation using Windows PowerShell