Decoupling Drupal to Use Only as a Backend

Introduction:

Let’s be honest here. Drupal is not particularly known for its themes or its intuitive UI. The emergence of frameworks like Angularjs and Reactjs also doesn’t help this fact. Developers are opting for these frameworks for better site visuals that will eventually improve the site’s productivity.

In this blog, we are going to see how to use Drupal purely as a backend framework that gives the data so that we can setup the frontend of the site using Angular or React.

Essentially, we are going to decouple Drupal and the frontend framework and maintain them separately.

 


THINGS TO NOTE BEFORE STARTING

  • We are going to be listing the Events in the Drupal as a sample requirement.
  • Also, we will be focusing more on Drupal part rather than Reactjs in this blog.
  • This blog assumes that you already have a considerable experience with Drupal and Reactjs to work individually with them.

Steps to Create a Sample API:

  • First, we need Drupal and Reactjs environments already available in the machine
  • In Drupal, in the configuration page enables all the web services that are available.
  • Use of services, RESTFUL API and Services Views modules are highly advised.

Drupal

  • Create a new View “sample view” or whatever name and select the provide REST export as an option. Also specify the URL endpoint for the API like “events/list”.
  • Add a filter criterion in the filter for content type as “Events”

Drupal img

  • Save the view.
  • That is all, a basic setup has been done to get the API response to the events listing in Drupal.
  • Goto <sitename>/events/list to get the listing of all the events.

Use the above URL in the Reactjs setup that you have created to get the listing and you can use that response along with Reactjs template coding to get a better looking site.


Some Useful Information About the Same:

The Services, RESTFUL api modules and other modules that we enabled to give us a set of general API endpoints that can be used from the get Go. Refer to the respective project page to get the full set of APIs available. This is just the tip of the iceberg. This blog is to show the bare minimum required to decouple Drupal and use it as a backend of a site.

Are You Looking to Hire Dedicated Drupal Developers for Your Project?

Some extra Ideas to Ponder:

Other ideas include using Angularjs as a frontend. Using Angularjs along with Cordova, we can even create a neat Android and IOS app for our site.

 

For more info Go to this link https: //cordova.apache.org/.

https: //ionicframework.com/ is also another platform that can be used for this.

 

Also Read: Drupal Module Development : Custom or Contributed?

 

Contributed By:

Anand Kumar

Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge