Drupal is a wonderful CMS that is used widely by many people. At regular intervals, Drupal introduces its updated versions. Recently, the new version of Drupal – Drupal 8 was launched. Here, we will discuss how Node.js and Express JS can be implemented and linked to Drupal CMS via a Restful API.
So, before heading on with this blog; we think that you already are aware with:
Express JS: Express JS Framework makes it easier to publish websites with Node.js. It provides routing and can be used with dynamic website applications as well as MVC based.
So, first let us understand how Drupal can be installed and configured:
- Installing and Configuring Drupal Core: Drupal 8 core contains Restful API that allows you to implement the GETs very quickly. Additional modules are to be written when we are dealing with Drupal 8 and then choose the minimal installation as we only need API as well as some additional modules.
Once Drupal 8 is installed; one can first activate Drupal administrative theme in order to get a graphic backend.
Now, the Toolbar module is to be installed for easier navigation via Drupal backend. The modules field is also needed in order to configure content type.
And the module “Views UI” defines the restful Web Service.
- Unnecessary Blocks: A little clean up is to be performed here. Still, there are two unnecessary blocks at the top of the page: Tools & Administration. These blocks can be removed under admin structure block.
- Content type “Blog”: A content type blog must include these fields: Title, Body and Image.
Define Drupal 8 content type as well as fields. For the blog, an Image field is needed as other required fields and data are already provided by Drupal core.
Configuring Drupal8 Web Service:
Here, the content type is defined and the required Web Service can be created. First create a new view ( Admin/ structure/views/add)
Now, export the “Rest” and make sure to check it. Then give it the name “Blogs JSON export” as well as the URL “blogsexportall”.
Configuring Drupal 8 Rest export View:
Under “Show” choose “Fields” instead of ‘Entity’. The fields required here will be:
- Title: Formatted “plain text” will be used with “link to content”.
- Authored on: The custom format YMD is to be used as it is the right format for schema.org which will be used in the front end.
- Blog Image: Here, large image will be added with the text on the top of the blog with Image Style “None” and “Link image to: nothing”.
- Authored on: This will be used for the date of the blog item with the custom format DYM.
- Body: It will be used for body text on the blog detail page with all default settings
- Authored by: This will be used for the name of blogger with all default settings.
- Author image: The author image is to be added at the bottom of the blog with all default settings.
- Author signature: The signature of the blogger is to be used with his her name at the bottom of the blog with all default settings.
This is the minimal sort of Drupal installation done here along with its configuration so that it can have backend where content managers can manage blogs. It subsequently generates data in proper format.
For more such guidelines and updates about Drupal, stay tuned with Softqube Technologies, Drupal web Design India.