March 26, 2023

Blog @ Munaf Sheikh

Latest news from tech-feeds around the world.

Upgrade your (Dato)CMS experience with custom plugins

Now that you have an idea of what you can use plugins for and where to find them, it is time for the next step: creating your own plugin, when it is not yet created by the community. We offer you the necessary guidelines to get started. 

A plugin is nothing more than an iframe within DatoCMS. This is a piece of HTML code that can call up a frame from another website and place it on your website. Within this frame everything can happen that you want to show with a plugin, from adding a Youtube video to adding a map from Google Maps. This implies that you can also use a self-hosted plugin, as long as there is a working url in the plugin settings, or the plugin has been imported through the DatoCMS plugin library itself. 

How do you get started with your own plugin?

  1. First you import the DatoCMS plugin SDK. 
  2. On the window element you initialize the plugin. 
  3. The init on DatoCmsPlugin has an init property which is given a function that exposes a variable. For the sake of simplicity we will call it a plugin. 
  4. The plugin contains everything you need to use your plugin.

The methods and options you can use are well described here. DatoCMS also provides specific steps for a field editor plugin, field add-on plugin and sidebar widget plugin. 

Attention: uploading to npm needs specific settings. A specific name and the package.json should look like what DatoCMS requires. Otherwise the plugin will not be picked up by their system. It will take some time before you will find your plugin in the plugin marketplace of Dato. 

Source link