ContentTypeSidebarWidget
ContentTypeSidebarWidget
The ContentTypeSidebarWidget object provides content type management and schema tools within the Contentstack UI.
const contentTypeSidebar = sdk.location.ContentTypeSidebarWidget;
if (contentTypeSidebar) {
const contentTypeData = contentTypeSidebar.getData();
contentTypeSidebar.onSave((updatedType) => {
console.log('Content type updated:', updatedType);
});
}getData()
The getData() method retrieves the current content type data.
const contentTypeData = contentTypeSidebar.getData();
console.log('Content type:', contentTypeData.title);
console.log('Schema:', contentTypeData.schema);onSave(callback)
The onSave() method listens for content type save events.
contentTypeSidebar.onSave((updatedContentType) => {
console.log('Content type saved:', updatedContentType);
// Handle the updated content type
});currentContentType
The currentContentType property retrieves the current content type object directly.
const contentType = contentTypeSidebar.currentContentType;
console.log('Current content type:', contentType);