Discover our Decoupled Drupal Approach

Drupal has been a very popular content management system since 2001 and has evolved into a large-scale used solution, having over 1 million websites that use it as a platform. Nowadays, Drupal 9 offers a variety of implementations, providing flexibility and customization at various levels, with the possibility of customizing its services to a perfectly tailored solution for the project’s needs.

This is mainly acquired by using Drupal as a decoupled back-end, thus allowing the front-end part to be developed in various technologies. While the future of web applications seems to be microservices, exposing content or entities to the front-end enables the use of any technology to render the application.

Decoupled Drupal approach
Decoupled Drupal Scheme

Decoupled Drupal Services

Decoupled Drupal

Also called Headless Drupal, stores and manages data and makes it available through web service APIs

Drupal back-office

Developers can fully benefit from the CMS aspect, creating fieldable entities, complex data structures, and vast editable content

Decoupled Drupal Services
Decoupled Drupal Services

Drupal’s core

Any logic needed or functionality is developed in custom modules, which plug into Drupal’s core through services

RESTful APIs

(API that conforms to the REST-style architecture), we can send the data in JSON or XML formats

Drupal RESTful solution

Below we have Drupal’s core and contributed modules that can help develop a decoupled solution.

REST views – this module enhances the REST export functionality by providing a link between views and REST, thus enabling us to expose any content type or entity defined in our backend

Serialization – responsible for deserializing and serializing request-response data

Simple Oauth 2 – this module allows users to log in and be authenticated using access tokens, thus removing the login layer and replacing it with secure, modern authentication

REST UI – this module exposes our web services configuration via the admin UI – this applies, of course, to our many custom endpoints through which we use various HTTP methods

Why Tremend

Tremend has a highly experienced team of software engineers and a special-dedicated Drupal department specialized in this area. Having worked with multiple traditional Drupal implementations or decoupled solutions, we can offer modern solutions and strong, secure architectures that can be implemented in various front-end technologies, like React Native or Vue.js.

A custom REST resource is defined using a Resource Plugin. Plugins are small pieces of functionality that have a certain purpose. In this case, we have to extend the ResourceBase plugin, add the proper namespace, configure the endpoint using annotations, implement the needed static methods (get, post, patch, etc.) and define the route parameters.

/**
* Provides a Tremend Resource
*
* @RestResource(
*   id = "tremend_resource",
*   label = @Translation("Tremend Resource"),
*   uri_paths = {
*     "cannonical" = "/tremend_rest_api/tremend_resource"
*   }
* )
*/
class TremendResource extends ResourceBase {

  /**
   * Responds to entity GET requests.
   * @return \Drupal\rest\ResourceResponse
   */
  public function get() {
    $response = ['message' => 'Hello, World!'];
    return new ResourceResponse($response);
  }
}

Applicability

Using Drupal as a headless back-end implementation allows us to serve content and complex flows, from user registration, authentication, and user groups, to a dynamic feed, tailored to various flags that the user chooses through the application, and a shop functionality that enables users to redeem prizes or products, and is always in sync with the back-end defined stock and options. In this way, we can serve this solution to many types of devices, including:

Applicability

Websites and native mobile apps

Internet of Things
apps

CRM systems

Different services will use the most appropriate technology through this approach, fostering reusability, scalability, cost reduction, and continuous delivery.

Get in touch

We are always happy to talk

Phone

+40-21-223-7700

Email

hello@tremend.com

Address

165 Splaiul Unirii, Timpuri Noi Square,
TN Office 2 building, 4th floor,
District 3, Bucharest, Romania, 030134






    Inspired by Drupal’s philosophy of contributing code and modules for the community, we have released a module that provides ePayment support in Drupal Commerce. Available here.

    Just install the module, configure standard ePayment parameters and you’re ready to process payments. You can also set a debug mode for the IPN confirmations and switch between production and test mode from the Drupal admin, very handy for a Drupal live site.

    Feel free to extend it and contribute some more to the Drupal community.

    Our first Drupal module: http://drupal.org/project/taxonomy_additions ads various additions to the core Taxonomy module. Meet Andrei (amateescu at tremend.ro) in Brussels at Drupal Developer Days 2011, 4-6 February.[QR]

    The usual way for Drupal is to have it live at the root of your website. It’s all nice if the only thing on your site is Drupal, but it gets very cluttered when you have other top-level directories.

    One customer had his corporate site at, say, “www.example.com“, and his customer support pages at “www.example.com/support“.  We wanted to keep the application in the “support” directory, and move all the drupal directories under “corporate“. And keep the old links working.

    First, we had to let Drupal know that, even if it’s been relocated to “corporate”, the URL still remains the same. Do it in “corporate/sites/default/settings.php“:

    $base_url = 'http://www.example.com';

    Then tell Apache that Drupal has moved. Put these rewrite rules in .htaccess at the root of your website.

      RewriteEngine on
     
      # Rewrite www.example.com to the Drupal home page: www.example.com/corporate/index.php
      RewriteRule ^$ corporate/index.php [L]
      # Let Drupal process paths like www.example.com/corporate/about
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^corporate/(.*)$ corporate/index.php?q=$1 [L,QSA]
    
      # Search for real Drupal files that moved, 
      #  (e.g. www.example.com/flash/intro.swf to www.example.com/corporate/flash/intro.swf)
      RewriteCond %{DOCUMENT_ROOT}/corporate/$1 -f
      RewriteRule ^(.*)$ corporate/$1 [L]
    
      # Let Drupal process all paths that are not real files and directories, like www.example.com/about
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} !=/favicon.ico
      RewriteRule ^(.*)$ corporate/index.php?q=$1 [L,QSA]
    
      # What's left are real non-Drupal pages and directories, like www.example.com/support
    

    Using some functionalities from this script I managed to port a Xaraya 1.4 installation to Drupal 6.13.

    The script performs the following tasks:

    • imports users
    • imports articles and comments
    • imports forums and comments
    • imports content types
    • imports vocabularies and terms
    • imports files

    The first thing I’ve done was to eliminate the sequences table, which is deprecated starting from Drupal version 4.

    Next, when managing categories, I’ve used the xaraya categories with parent id equal to 0 as Content Types and Vocabularies and inserted all the others as terms associated with the vocabulary.

    The term hierarchy is created by running a script on the term_hierarchy table setting parent_id 0 for the first child and the original parent_id for the next ones.

    With regard to files and images, Inserting them into the ‘files’ table is not enough – the FileField
    and ImageField Drupal modules are mandatory in order to associate a field with a node. (this is still a work in progress)

    One last note: in order to maintain database integrity, the original id-s must be used in all tables.