Custom widgets let you integrate powerful functionalities into your stack that let you analyze your entry content and recommend ideas. Some examples of custom widgets are SEO tag recommendations, sentiments analysis, and language translation.
Add Custom Widgets
There are two ways to add a custom widget to a content type:
You can create new custom widgets by writing your custom code, or you can use the prebuilt templates by modifying the given code to suit your requirements. Let’s look at both the methods in detail.
Create new custom widgets
In this guide, we will learn how to build a new custom widget from the ground up.
We have step-by-step custom widget setup guides for some popular third-party apps. The details can be found in the corresponding articles given in the list below. Or you can refer to our general guide on creating a custom widget.
Let’s look at the steps involved in creating and deploying the custom widget in Contentstack.
Go to Settings > Extensions.
Click Add Extension and select Create new.
From the two options, select Custom Widget.
On the page that appears, enter values in the fields as given below:
Title: Provide a suitable title for your custom widget. This title will be visible as a widget name in the entry page.
Hosting method: Select how you wish to host the widget. If you select ‘External Hosting’, you need to provide the URL on which you have hosted the widget, in the URL field that appears below. If you select ‘Hosted on Contentstack’, you can write the code in the ‘Extension source code’ that appears below after selecting this method.
External source code: Enter your custom widget’s source code. You can find an example here.
Config Parameter: If you have used any config parameters (such as access token) in the source code, specify the value of the parameters in the ‘Config Parameter’ field.
Scope: Select which content types this widget will be available for. You can choose All Content Types or Specific Content Types.
Click ‘Save’. This will create your custom widget extension.
Once your custom widget is created, you will be able to use them in the entries of the specified content types.
Use prebuilt templates
Contentstack provides certain prebuilt custom widget templates, so that you can get started instantly instead of writing code. You just need to configure these templates a bit and get started.
Below is the list of prebuilt templates that Contentstack provides: