Skip to main content

    When was the last time your website had a facelift or created a strategy to improve your brand visibility in versatile, exciting, and engaging ways? Revamping your website with interactive content and improved user experience delivers true value to your organization. Website redesigning with a contemporary design, modern trends and enhanced functionality improves your bottom line. 

    Why not make invest your time and money in trusted and reliable CMS platform? With a better looking website and navigation experience, drive heavy traffic to your website and easily convert even casual visitors into customers. Even better, when you redesign your website’s content with the most modern content management system like Drupal 8 to take the pain out of your IT problems. 

    Drupal is a free, open source software, produced by over a million users in 230 countries speaking 181 languages. Drupal is the best CMS platform for web content management among global enterprises, governments, higher education institutions, and NGOs. Drupal is highly flexible, secure and scalable to serve your technical and business requirements in Drupal 8 development. Drupal 8 offers powerful digital solutions and is backed by one of the world’s most innovative open source communities.

    Here are ten important benefits of redesigning your website with Drupal 8 to meet your business goals:

    1. Easy Content Authoring

    Drupal is built with essential tools for content creation and publishing, like a customizable WYSIWYG editor to meet the unique requirements of authors, publishers and Drupal developers. Drupal offers role-based permissions for managing editorial workflows as well as content.

    2. Responsive Design

    According to a recent survey, consumers spend five hours on mobile devices every day. Thirty percent of Google searches are now being performed on some sort of mobile device. Drupal leverages responsive design technology to access content on-the-go from various screen sizes and devices such as iPhone, Android, and others.

    3. Usability & User Experience

    When an UX is developed well in a website, visitors will easily find the information they need without delay and frustration. Even though the quality of content, graphic design, and the reputation of a company is great, a website design that is not logical and orderly leads to a bad user experience.

    4. Image Optimization

    Images causes some sites to be painfully slow. Drupal 8 websites are amazing with beautiful images optimized for search engines and you can save on data as well.

    5. Website Performance 
    Optimizing the speed of the web pages by minimizing HTTP requests, minifying HTML, CSS and Javascript, caching, deferring parsing of javascripts, avoiding bad requests and using content delivery networks can just ensure a rewarding browsing experience.

    6. Data Migration

    If you're running into a lot of roadblocks when you try to update your current site, you have to redesign with a new CMS. Drupal 8 allows you to very easily import your database  including critical pages, images, or downloadable files 

    7. Website Security

    Drupal 8 is built with comprehensive security by default to safeguard website content and manage its accessibility. The important security features and improvements include HTML generation with Twig templates, cross site scripting, SQL injection, use of PHP as input format, improved content entry and filtering, route definitions, clickjacking protection, CSP support, and more

    8. PHP 7 Compatibility

    Drupal 8 is PHP 7-ready and sites that run many contrib modules, or particularly memory-intensive need increased memory requirements.  Drupal 8 performance optimization with PHP 7 maximizes the overall page speed and performance of the website.  

    9. SEO-friendly CMS

    Search engine optimization is an integral part of any website. Drupal 8 comes with out-of-the-box built-in SEO features to drive heavy traffic to the website and improve search engine rankings. Drupal 8 is optimized for SEO with increased site speed, responsive web design, mobile-readiness, content-as-a-service capabilities, clean URLs, advanced search, multilingual sitemap and more to increase the reach and visibility of your website.

    10. Multilingual Website

    Drupal publishes a single web site or shares content in multiple languages across multiple devices. Drupal 8 is configured with complete and powerful translation module with multiple language handling, interface translation, content translation, and configuration translation to deliver better experience than ever before and save incredible amount of time and money.

    Drupal 8 is powered with improved features and functionality, and as the platform matures, it is poised to become the backbone of more and more digital experiences.

    Drupal is PHP 7-ready and sites that run many contrib modules, or particularly memory-intensive ones, will need more memory requirements. Optimizing Drupal website performance with PHP 7 version will boost the overall page speed. 

    PHP 7 was released in December 2015 and offers high performance, huge load capacity and asynchronous programming support  for online applications. According to the latest study, PHP 7 is twice as fast as PHP 5.6 and reduces memory usage.

    PHP 7

    Why this is the right time to move to PHP 7

    Drupal 7 core officially supports PHP 5.2.5 or higher  However, PHP 7 introduces backward incompatible changes which may need to be addressed in contributed or custom modules and themes. While some Drupal 7 sites may run on minimum of PHP versions, you can move to Drupal 8 with PHP 7 support to enhance the performance of the site.

    Drupal 8 officially supports 200+ new features and improved functionalities, and upgrading to PHP 7 brings a lot of improvements and delivers high performance Drupal site, whether you are a website owner or a Drupal developer

    Drupal core's automated test suite is now fully passing on a variety of environments where there were previously some failures (PHP 5.4, 5.5, 5.6, and 7). Several bugs affecting those versions were fixed as well. These PHP versions are officially supported by Drupal 7 and recommended for use where possible.

    Anecdotal evidence from a variety of users suggests that Drupal 7 can be successfully used on PHP 7, both before and after the 7.50 release. 

    A slow website load time impacts visitors, overall user experience, and the bottom line. With the improved speed enhancements of Drupal 7 and Drupal 8 with PHP 7, your user engagement and experience will increase and less likely they will leave your website

    Drupal is a comprehensive content management framework which offers a number of modules to extend its functionalities with day-to-day updates. If you want to know about ‘Drupal Maintenance’, then you need to know the following things: 

    Security updates

    • Upgrade from Drupal 6 to Drupal 7 or Drupal 8
    • Migration from legacy system

    Security updates

                       Updating refers to taking your site from one 'minor' version to another minor version. Lets consider an example if a site is in Drupal 7 version D7.1 and latest version is released as D7.2 or from Drupal 8 version D8.1.0 to D8.1.3 then its an update.

    Version Upgrades

                     Upgrading refers to taking your site from one 'Major' version to another major version.Switching from Drupal 6 to Drupal 7, or from Drupal 6 to Drupal 8, or from Drupal 7 to Drupal 8 is an 'upgrade'.

    Drupal Migration

                   You may want to 'migrate' your site from running locally on your computer to an online webhost. Or you may want to 'migrate' your site from one webhost to another. If that is what you want, head to: Backing up and migrating a site.

    Steps to Drupal 7 upgrade 

    • Log-in as an user with administrator privileges who can perform "Administer software updates".
    • Turn your site into maintenance mode. Ie. If we are updating a live/production site then go to Administration > Configuration > Development > Maintenance mode. Enable the "Put site into maintenance mode" checkbox and save the configuration.
    • Backup your files and database. Clear the performance cache and delete all the watchdog logs, if any, before taking the database backup.
    • Remove all old core files and directories, except for the 'sites' directory, the original install profile in the 'profiles' directory and any custom files (like htaccess, gitignore or other files) you added elsewhere.
    • To be more specific, in your Drupal root directory, delete all files and the following directories: includes, misc, modules, scripts, and themes. If you made a normal installation, then also delete the profiles folder, but if you used a custom profile, then in the profiles folder, delete the subfolders minimal, standard, and testing.
    • Modifications to the files like .htaccess or robots.txt, needs to be applied from your backup, after the new files are kept in place.
    • Read the release announcement carefully before proceeding the upgrade as the updates may also include changes in settings.php. If you have to use the new settings.php file, then replace the settings.php with the default.settings.php, and apply the site-specific entries like database name, user, and password from the backup file.
    • Any custom files and directories outside the sites directories has to be placed manually. However, it is recommended not to have any custom files or directories outside the sites directory.
    • Download the latest Drupal 7.x core release from to a directory outside of your web root. Extract the archive and copy the files into your Drupal directory.
    • After copying the new core files, run update url by visiting http://YOURSITENAME/update.php. This will update the core database tables if any alteration to the database table structures is there.
    • In order to access the update.php file please login as administrator. Before you start doing the upgrade process, we have logged in as admin user, get access to the update.php file automatically. In case you had logged out or closed the browser by mistake, you can do the following to access the update.php file.

               Open settings.php with a text editor.
               Look for $update_free_access variable.
               $update_free_access = FALSE;
               Change the access to true:
               $update_free_access = TRUE;
               Now run update.php.

    • Once the update is completed, check for errors if any. $update_free_access must be changed back to FALSE for security reasons.
    • Clear the sites performance cache after the upgrade. You can do it by navigating to Configuration => Development => Performance and "Clear all Cache".
    • Check for the status report and report log to verify that everything is working as expected.
    • Once you are error free, make the site online to change the "Put site into maintenance mode" checkbox and save the configuration.

    Tips for Drupal site maintenance

    • Keep the Drupal core up-to-date
    • Keep the contributed Drupal modules up-to-date. 
    • Check for the security updates. Install update manager to know the latest available and recommended releases for Drupal core and its contributed modules
    • Configure cron scheduler so that periodic site maintenance will take care of regular checkup and updates
    • Keep the admin user password secure
    • Ensure using check_plain method while assigning or computing values from form post fields to avoid cross-site scripting
    • Write protect the setting.php file.

    Learn about the Drupal community coding standards and best practices that every Drupal developer should care whenever writing the code for Drupal. If you are truly committed to Drupal, then you should guarantee the code you contribute back be standards compliant. Here are ten of the best practices for implementing Drupal coding standards:

    1. Spacing and Tabbing

    • Use double space (not tab, yes both are different) for indentation 
    • Often, the IDE/Editor that we use for Drupal development aggravates this issue as most of the IDE is configured to use tab for every line-break.
    • Press <ENTER> ensure that it aligns the cursor to the same indent as previous line with tabbing that caused this indentation issue.

    2. Code comments

    • Check this link below for Drupal comment standards ( Comments are generally defined and used to state what the following line of code or block of code is doing and why we are writing the logic that way if it needs explanation for any future Drupal developer.
    • Three types of comments can be used in Drupal, Single line commenting (starts with //), Multi-line commenting (starts with /*) and Doxygen commenting (starts with /**).
    • Single line commenting and Doxygen commenting has a wide following in Drupal. Even for the comments with more than a line, it is handled with repeat use of single line commenting. The following example shows the usage pattern:

             // The first line of the comment goes here.
            // Some other comment here.
            // Some more comments here.
            // This saves the $node object and creates/updates the node

    • Comments are strictly not to be used to invalidate the code, which means you can’t use the comments to comment-out some set of code that you think are not needed. 
    • If you think some block of code is not really needed, just remove them instead of commenting-it-out. 
    • Sometimes you might find, the block of code that may be needed in future but not needed right now. In such instances, you can invalidate the code by placing those unwanted code in the condition like mentioned below.

             if (0) {
             // Some big logic goes here
            // that are not needed in this release for production

    • The above code gets invalidated, that is will not be executed ever as the condition "if (0)" always returns "FALSE", So the block of code inside that condition will not be executed.

    3. Naming the function and variables

    • PHP was just procedural at the time of initial Drupal release. So all the coding standard in Drupal follows as such. That means all the function and variables should follow snake  case structure (as of Drupal7), which means variable names should start with small-letter words and underscore should be used to connect the words if the variable is going to contain multiple words. ($snake_case)
    • With the release of Drupal 8, the naming of variables and functions can also be used using camelCase structure, which means variable names should start with small-letter words with uppercase initials for the connective words in case of multi-word variable. (Eg. $camelCase)
    • In either way, we need to follow only one case throughout the file.
    • What we forget is, we mix cases (camelCase and snake_case) sometimes. This should be avoided. Sometimes we define functions without grouping of the function name. In Drupal, all the functions inside a module should be prefixed with the module name, which is called grouping of the function. This helps in avoiding the name conflicts between modules.

    4. Uppercase variables

    • According to Drupal coding standard, UPPERCASE variables are considered as constants whether it's PHP constants (TRUE, FALSE, NULL) or Drupal constants (Eg: LANGUAGE_NONE).
    • Sometimes in order to stress the importance of variables, we name the variables in uppercase. This should be avoided.

    5. Operator and logical statements

    •  We often forget to leave a space before and after the usage of operator (Eg. if(arg(0)=='node')). According to the Drupal coding standards, all the operators should have single space before and after the operator (Eg. if (arg(0) == 'node')).
    •  Use single space before the start curly braces. The opening curly should be on the same line as the opening statement, guided by single space. The closing curly brace should be on the end of the block and indented to the same level as the opening statement.

    6. Line length and Wrapping

    • In general, all lines of code should be no longer than 80 characters. However, there are exceptions to the character limit for the variable and function name that are quite longer when correctly indented.
    • We often wrap the condition of the control statement for readability. Drupal coding standard encourages us to split the multiple conditions and evaluate each complex conditions into a variable and use that in the control statement for better readability.

    7. Module placement

    As far as Drupal 7 is considered, all the contributed modules should be grouped under the directory called "contrib" in "/sites/all/modules", whereas the custom modules should go inside "/sites/all/modules/custom". In Drupal 8, the same can be followed or utilize the "/module" directory and use the same grouping of the  modules.

    8. Writing Javascript

    • Always use Drupal behavior for your custom scripts which runs every time there is change in DOM elements unlike the traditional jQuery.ready which runs only once during the page execution when the DOM elements are ready.

    9. Placeholders for translate function t()

    • Use the placeholders for dynamic strings used inside t() function.
    • Generally t() function is used to translate the given strings, sometimes we might use the dynamic strings inside t() function by concatenating the values, which is the not the best practice formulated by Drupal.


    • return t('@username, welcome to my website', array('@username' => $account->name));

    10. Module file

    • Use the module file only for Drupal hooks and some commonly used custom functions that you need frequently. 
    • Use .inc file to define menu callbacks and other helper functions that are not needed to be defined in module file.

    If we all code to standards, Drupal will be a stronger, more performant, more secure platform. Drupal will continue to grow and strengthen it’s community due to the quality of it’s codebase. Anubavam has been building Drupal sites and providing services such as Drupal 8 upgrade and migration services, Drupal E-commerce development services, and more. Anubavam is participating in Drupal core development since 2006 and has delivered 250+ projects to 100+ happy clients in 22 countries worldwide.

    In our earlier article, we had a solid understanding of Drupal 8 theming. In this post, we're going to dig into the theming fundamentals, files for styles, JS, CSS, library, Twig templates , adding new regions, attach the library to all the pages and working with breakpoints in Drupal 8 development.

    Creating a Drupal 8 sub-theme

    Sub-themes are just like any other theme, with one difference: they inherit the parent theme's resources. There are no limits on the chaining capabilities connecting sub-themes to their parents. A sub-theme can be a child of another sub-theme, and it can be branched and organized however you see fit. This is what gives sub-themes great potential.

    To create a sub-theme you define your theme like any other theme and declare the base theme using the "base theme" key. Note that the key has no underscore.

    Create an .info.yml file

    To create a Drupal 8 theme you need to first create a file that provides meta-data about your theme to Drupal. This is similar to how modules and installation profiles are being defined, and as such it is important to set the 'type' key in the .info.yml file to 'theme' in order to differentiate it.

    If your theme is named “Flower" then the folder is named “flower/" and the .info.yml file is named "flower/"

    name: Flower
    type: theme
    description: 'A flower theme that offers extra fluffiness.'
    package: Custom
    core: 8.x
      - flower/globalstyling
      - '@classy/css/layout.css'
      - core/assets/vendor/normalize-css/normalize.css
      header: Header
      content: Content
      sidebar_first: 'Sidebar first'
      footer: Footer

    Folder Structure

    In Drupal 8, we can use the "themes" folder to add a new theme. You should note that Drupal core themes such as Bartik and Seven are located in the core/themes folder of your installation.

    The best practice is to place the contributed themes in a sub folder named "contrib" and your own themes in a folder named "custom".

    Here are some examples of files and folders that are structured in the new theme folder structure:

     |  |-install
     |  |  |-flower.settings.yml
     |  |-schema
     |  |  |-flower.schema.yml
     |  |-style.css
     |  |-flower.js
     |  |-buttons.png
     |  |-maintenance-page.html.twig
     |  |-node.html.twig

    Twig in Drupal 8

    Twig is a template engine for PHP and it is part of the Symfony2 framework. One of the results of this change is that all of the theme_* functions and PHPTemplate based *.tpl.php files have been replaced in by *.html.twig template files. Learn how to use the twig template engine in Drupal 8.

    Adding Regions to a Theme

    Adding region meta-data to your file
    - Editing your page.html.twig file and printing the new regions

    Declaring any new regions in your file. Regions are declared as children of the regions key like so:

    # Regions
      header: 'Header'
      content: 'Content'
      footer: 'Footer'


    header: 'Header'
    Will become:

    {{ page.header }}

    In your Twig templates.

    Adding (CSS) and JavaScript (JS) to a Drupal 8 theme

    In Drupal 8, stylesheets (CSS) and JavaScript (JS) are loaded through the same system for modules (code) and themes.

    Defining a library

    To define one or more (asset) libraries, add a *.libraries.yml file to your theme folder. (If your theme is named fluffiness, then the file name should be fluffiness.libraries.yml). Each "library" in the file is an entry detailing CSS and JS files (assets)

    Defining JS files

      version: 1.x
          css/cuddly-slider.css: {}
        js/cuddly-slider.js: {}
        - core/jquery

    Defining CSS file

    Defining CSS file
      version: 1.x
          css/layout.css: {}
          css/style.css: {}
          css/colors.css: {}
          css/print.css: { media: print }

    Attaching a library file

    • Attaching a library to All page(s)

      To attach a library to all the pages on the site that use your theme, declare it in your theme's *.info.yml file, under the libraries key:

      name: Flower
      type: theme
      core: 8.x
        - flower/cuddly-slider

      You can list as many libraries as you want, all of them will be loaded on every page.

    • Attaching a library to a subset of pages :

      A theme can make this happen by implementing a THEME_preprocess_HOOK() function in the .theme file, replacing "THEME" with the machine name of your theme and "HOOK" by the machine name of the theme hook.

      For instance, if you want to attach JavaScript to the maintenance page, the "HOOK" part is "maintenance_page", and your function would look like this:

          function flower_preprocess_maintenance_page(&$variables) {
             $variables['#attached']['library'][] = 'flower/cuddly-slider';

    Including Default Image Styles With Your Theme

    The process for including an image style in your theme is similar to that of including default configuration in a module.

    • Create the Image Style you wish to include using the UI
    • Export the Image Style as YAML
    • Include the exported YAML in the config/install directory of your theme following the appropriate naming convention.
    • Start by creating an image style using the admin UI at Configuration > Image Styles (admin/config/media/image-styles). Once the image style has been created and saved, the configuration that makes up that image style will be stored in your site's active config.

    This configuration can be exported using:

    • Single import/export tool at Configuration > Configuration management > Single Import/Export > Export (admin/config/development/configuration/single/export).
    • From the configuration type select list choose "Image style" then choose your image style from the configuration name select list.

    Example: flower/config/install/

    langcode: en
    status: true
    dependencies: {  }
    name: black_white
    label: 'black & white'
        uuid: 8d4f85cc-9a2d-4a30-af15-21b0833dc06d
        id: image_desaturate
        weight: 1
        data: {  }
    third_party_settings: {  }

    Working with breakpoints in Drupal 8

    Breakpoint's properties

    • label - A human readable label for the breakpoint.
    • mediaQuery - Media query text proper all and (min-width: 851px).
    • weight - Positional weight (order) for the breakpoint.
    • multipliers - Supported pixel resolution multipliers.

    Example: flower.breakpoints.yml
    label: mobile
    mediaQuery: ''
    weight: 2
        - 1x
      label: narrow
      mediaQuery: 'all and (min-width: 560px) and (max-width: 850px)'
      weight: 1
        - 1x
      label: wide
      mediaQuery: 'all and (min-width: 851px)'
      weight: 0
        - 1x

    I hope this Drupal 8 theming guide illuminates the fundamentals of getting a theme started so that you can use it for Drupal projects.

    In Drupal 8, there is a need to store information associated with a user's session. There are two services for temporarily storing user-specific and non-user-specific data in key/value format, namely, use user.private_tempstore and user.shared_tempstore.


    A tempstore is for data that needs to be persisted between requests without being saved back to the canonical storage (such as an entity or configuration object).  

    Two methods can be effectively used for  private_tempstore - Use "\Drupal::service()" and Dependency Injection.

    Use "\Drupal::service()"

    To set Temporary Data

    $tempstore = \Drupal::service('user.private_tempstore')->get('mymodule_name');
    $tempstore->set('my_variable_name', $some_data);

    To read Temporary Data

    $tempstore = \Drupal::service('user.private_tempstore')->get('mymodule_name');
    $tempstore->get('my_variable_name', $some_data);


    A PrivateTempStore can be used to make temporary, non-cache data available across requests. The data for the PrivateTempStore is stored in one key/value collection. PrivateTempStore data expires automatically after a given timeframe.

    Dependency Injection

    • To use this service need to invoke the following “use” statement

              use Drupal\user\PrivateTempStoreFactory;

              use Symfony\Component\DependencyInjection\ContainerInterface;

    • Temporary store - that is private to the current user.

    Storing session data vs storing temporary data

    Which is efficient, storing data using session variable or use data for a limited term. Let's see which approach is preferable: 

    • Both are used for same purpose.
    • But Drupal 8 services provides needed abstraction and structure for interacting with a global construct. It's part of an overall architecture that allows Drupal developers to build and extend complex applications.
    • Use session manager for anonymous user to store the data.

    Stay connected with the latest news on web strategy, design, and Drupal 8 development.

    Site speed is crucial when you run a site. If a site takes too much time to load, visitors will get frustrated and leave the site to go elsewhere. Slower performing sites don't rank well on search engines.
    Drupal performance optimization can be a complicated specialization in its own right. It takes too long to investigate performance issues and fix them. However, here are some quick fixes and simple methods to move you into the right direction. 
    1. Keep the core, contrib module and themes updated
    It is critical that you are running the most recent Drupal version as updates by and large contain bug fixes and performance improvements. Keep the core, contribs module, and themes with the latest Drupal update.
    To run updates, navigate to “Reports” → “Available Updates.”
    You can then click on “Check manually” to scan for additional updates.
    2. Enable Page Caching  
    To enable, navigate to “Configuration” → “Development” → “Performance.”
    Enable “Cache pages for anonymous users” and also “Cache blocks.” You can then choose a time value for minimum cache lifetime and expiration of cached pages.
    Click on “Save configuration.”
    3. Turn on Block Caching 
    Enable caching options for all the blocks that will boost the performance.
    4. Aggregate Javascript and CSS files  
    Browser doesn’t have to fetch as many files and it reduces the total number of HTTP requests being made. Enhance your frontend performance and download times by aggregating your CSS and Javascript files.
    To enable, navigate to “Configuration” → “Development” → “Performance.”
    Enable “Aggregate and compress CSS files” and “Aggregate Javascript files.”
    Click on “Save configuration.”
    5. Disable unnecessary modules
    Every module adds to the amount of code that needs to be available for a page load. And it also increases the number of lookups. Wherever possible use a generic module in place of multiple module that does specific functionalities.
    6. Cache views content
    The views module is probably one of the most popular modules on Drupal 8 development. If you have it installed you can also enable caching on it.
    To enable, navigate to “Administration” → “Structure” → “Views.”
    Click “Edit” on the view you want to enable caching on.
    Expand the “Advanced box.”
    Select “Time-based” and click on “Apply (all displays).”
    7. Disable DB logging 
    When the Database Logging module is enabled, you're shown with a menu item in the "Logging and alerts" of the site configuration. When the Database Logging module is disabled, although the menu item for Database logging goes away, "Logging and Alerts" becomes empty and stays there. If you visit admin/settings/logging, you're shown with an empty page.
    8. Reduce 404 Errors
    Use third party services such as “online Broken Link Checker” or a tool like Screaming Frog and avoid using a module to check for 404s and save your server’s resources.
    Stay away from expensive 404 errors using Drupal Fast 404 module as it can normally such errors with less than 1MB of memory.
    9. Fast 404 Responses 
    When your site has broken images or CSS file paths, it will reduce the page speed significantly The Fast 404 module changes the way 404 errors are handled, delivering fast 404 error messages.
    10. Compress Images 
    The loading speed of large image files are slow. Make the file size smaller so they are not larger than they need to be. For image fields, you can use image styles (admin/config/media/image-styles) to resize images to the desired size.
    11. Use Sprite Sheets
    An image sprite is an aggregation of a single image. A web page loaded with a number of images is slow to load and generates multiple server requests. Reduce multiple server requests with image sprites and save bandwidth.
    12. Lazy Loading of Images 
    Lazy loading images can substantially increase your page load times by ensuring the image will only load when it is visible to the browser window. “Image Lazyloader” is the most popular Drupal module over 18,000 downloads.
    13. Content Delivery Network
    Implementing a Content Delivery Network (CDN) with Drupal is a fast and easy way to instantly see decreased load times for your website. Protect your digital assets such as product images, javascript, CSS across the world will ensure that they are delivered faster to your visitors and reducing latency.
    This represents a run down of 13 easier ways to boost the performance of Drupal sites. Track the changes to ensure that there is actually an improvement in the performance.
    Let me know in the comments below if you can think of any more quick wins to improve performance of a Drupal site.

    Most of the organizations are increasingly implementing web based mapping systems, this is where the importance of mapping to Drupal comes in.  Drupal 8 development offers amazing tools for mapping. It integrates with a lot of libraries, technologies and third party services. There are solutions for simple maps but also for complex mapping needs.

    If you start mapping with Drupal, you need to use a combination of location modules to achieve your goal.

    There are currently stable modules in Drupal that enable gathering, storage, processing and display of geospatial data;

    Setting up Drupal Mapping

    • Coordinate systems (the center of the earth, the plane of origin of latitude, & the plane of origin of longitude) 
    • Models of Earth (EPSG codes) 
    • Specifying a location (latitude, longitude, & height above a surface model) 
    • Map projections (flattening the Earth) 5
    • Location data (latitude & longitude) are special
    • They are not your typical data format: text/number/dates
    • Since you usually want to measure distances and areas, which are sensitive to coordinate systems & projections, they must be special objects to be efficiently handled by spatial functions
    • Also, we often want our points, lines, polygons to be easy to customize/style, we must create new data type format for this mechanism to be possible

    Applying geospatial data storage in Drupal CMS

    • KML, GPX, and GeoJSON are usually text file formats
    • WKT is usually implemented as a database object format, hence faster or more efficient to process. 
    • Keyhole Markup Language - XML variant, popularized by Google, default format in Google Earth 
    • GPS eXchange Format - XML schema designed for GPS data format, Native format in GPS-capable smartphones/devices 
    • GeoJSON -  JSON object ,  generally more compact than KML/GPX 
    • Well-Known Text - text markup language for representing vector geometry objects

    Drupal is a powerful Open Source CMS which has a large community of Drupal developers, designers and users. Drupal mapping continue to increase as more people become aware of the numerous benefits maps and GIS applications provide. The future is bright for a comprehensive Drupal mapping system that combines all the best geospatial modules.

    Drupal 8 Form API is similar to Drupal 7 form API. The forms are still represented with nested array structure as Drupal 7 to render the data. However, there is a separate validation and submission form as well.

    Form Generation

    • There are different classes, functions and interfaces to choose depending on the type of form you are creating.
    • Drupal 8 has some new HTML 5 elements (telephone, email, date) to render array structure.
    • The basic workflow of a form is defined by buildForm, validateForm, and submitForm methods of the interface.

    Create a Directory Structure

    Create a directory within a new custom module. 


    Create your formExample.module in below directory structure


    Form ID

    This needs to return a string that is the unique ID of your form. Namespace the form ID based on your module's name.


    Drupal 8

    public function getFormId() {
           return 'multistep_form_one';

    Drupal 7

    function multistep_form_one($form,$form_state) {


    This needs to returns a Form API array that defines each of the elements your form is composed of.


    public function bulidForm(array $form, FormStateInterface $form_state) {
           $form[‘name’] = array(
                ‘#type’ => ‘textfield’,
                ‘title’=> ‘name’,
           return $form;



    public function validateForm(array $form, FormStateInterface $form_state) {
               $form_state->setErrorByName(“Enter only alphabets”);



    public function submitForm(array &$form, FormStateInterface $form_state) {
        foreach ($form_state->getValues() as $key => $value) {
          drupal_set_message($key . ': ' . $value);


    We are done with creating custom form elements, fields, field formatters, etc. in Drupal 8. Our expert Drupal developers will be covering session data storage with Drupal 8 in future posts in this series. Join the conversation by commenting below with any questions or feedback on using these Drupal 8 constructs.

    With Drupal 8, significant changes has been brought for developers: new features and backwards-compatible changes, new APIs, deprecated modules, and more. One of the biggest changes is Drupal 8's unified database query API that fundamentally alters the way most Drupal developers will build database queries in Drupal.

    The following database types are supported in Drupal 7 & Drupal 8:

    Drupal 7

    • MySQL, MariaDB, or equivalent
    • PostgreSQL
    • SQLite

    Drupal 8

    • MySQL, MariaDB, Percona Server, or equivalent
    • PostgreSQL
    • SQLite

    Database abstraction layer - One query for all type of database

    Allow the use of different database servers using the same code base.
    Drupal provides a database abstraction layer to provide developers with the ability to support multiple database servers easily. 

    The intent of this layer is to preserve the syntax and power of SQL as much as possible, but also allow developers a way to leverage more complex functionality in a unified way. 

    It also provides a structured interface for dynamically constructing queries when appropriate, and enforcing security checks and similar good practices.

    It’s PHP’s PDO (recursive acronym of PHP Data Object. Definition: The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP).

    Drupal query

    Query Types:

    • Static Query
    • Dynamic Query

    Static and Dynamic queries

    Static queries 

    The most common form of query in Drupal is a static query. Only very simple queries should use the static query mechanism.

    Dynamic queries

    Dynamic queries refer to queries that are built dynamically by Drupal rather than provided as an explicit query string. All Insert, Update, Delete, and Merge queries must be dynamic.
    db_select, db_insert, db_delete, db_update, db_merge

    D7 db_query 

    Executes an arbitrary query string against the active database.

    db_query($query, array $args = array(), array $options = array())

    // Fetch the results from node table where the node belongs to specified ids


    db_query("SELECT * FROM {node} WHERE nid IN (13, 42, 144)");

    Using placeholders  (:placeholder_name)

    db_query("SELECT * FROM {node} WHERE nid IN (:nids)", array(':nids' => array(13, 42, 144));
    $nids = array(13, 42, 144);
    db_query("SELECT * FROM {node} WHERE nid IN (:nids)", array(':nids' => $nids);

    Note: Curly braces ( { } ) are not mandatory in either case

    D8 db_query

    Executes an arbitrary query string against the active database.

    db_query($query, array $args = array(), array $options = array())

    Note: Drupal8 discourages us to use db_query as it is marked as deprecated in Drupal8 and will be definitely removed from Drupal 9.

    D7 db_select
    Returns a new SelectQuery object for the active database.

    db_select($table, $alias = NULL, array $options = array())  

    // Fetch the results from node table where the node belongs to specified ids


    $result = db_select(node, 'n')

    Select particular column 

    $result = db_select(node, 'n')
        ->fields('n', array('nid', 'title'))

    Note: Curly braces ( { } ) are not mandatory in either case

    D8 db_select
    Returns a new SelectQuery object for the active database.

    db_select($table, $alias = NULL, array $options = []) 

    Tips: [] is supported since PHP version 5.4, it can be used instead of specifying array().


    $db = \Drupal::database();
    $result = $db->select('node', 'n');
        $query->condition('type', "page", "=");
        $result = $query->execute()->fetchAll();

    D7 db_insert
    Returns a new InsertQuery object for the active database.

    db_insert($table, array $options = array()) 


    $nid = db_insert('node')
      'title' => 'Example',
      'uid' => 1,
      'created' => REQUEST_TIME,

    /** similar to **/

    $result = db_query("INSERT INTO {node} (title, uid, created) VALUES (%s, %d, %d)", 'Example', 1, time());

    D8 db_insert
    Returns a new InsertQuery object for the active database.

    db_insert($table, array $options = array()) 


    $conn = Database::getConnection();
        'sender_name' => $name,
        'sender_email' => $email,
        'sender_subject' => $recipient,
        'sender_message' => $message,

    D7 db_update
    Returns a new UpdateQuery object for the active database.

    db_update($table, array $options = array()) 


    $num_updated = db_update('node')
        'status' => 1,
      ->condition('uid', 5, '=')

    // Above Example is Equivalent to the following:

    $result = db_query("UPDATE {node} SET status = %d WHERE uid = %d", 1, 5);

    D8 db_update
    Returns a new UpdateQuery object for the active database.

    db_update($table, array $options = array())


    $query = \Drupal::database()->update('file_managed');
    'uri' =>$uri,
    $query->condition('fid', $fid, ‘=’);

    D7 db_delete

    Returns a new DeleteQuery object for the active database.

    db_delete($table, array $options = array())


    $num_deleted = db_delete('node')
      ->condition('uid', 5)

    equivalent to →DELETE FROM {node} WHERE uid=5;

    D8 db_delete
    Returns a new DeleteQuery object for the active database.

    db_delete($table, array $options = []) 


        ->condition('module', 'menu')
        ->condition('delta', $delta, ‘=’)

    D7 and D8 db_merge
    Returns a new MergeQuery object for the active database.

    db_merge($table, array $options = array()) 


      ->key(array('name' => $name))
          'field1' => $value1,
          'field2' => $value2,

    Returns a new TruncateQuery object for the active database.

    db_truncate($table, array $options = []) 



    Both D7 and D8 shares the same syntax, but in D8 its mentioned as deprecated and advised to use dependency injection for such operations.

    Sets a new active database.

    db_set_active($key = ‘default’) 



    Note: Deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Use \Drupal\Core\Database\Database::setActiveConnection() instead.

    Retrieves entities matching a given set of conditions.

    • When building complex web applications, you’ll eventually have to interact with a database. 
    • To retrieve data in Drupal one can use the database abstraction layer provided, which requires some SQL knowledge to be used properly. 
    • When Drupal 7 EntityFieldQuery API is provided, it lets you fetch information about entities from Drupal without actually building SQL queries. 

    D7 example

    $taxonomnyQuery = new EntityFieldQuery();
      $terms = $taxonomnyQuery->entityCondition('entity_type', 'taxonomy_term')
        ->propertyCondition('vid', 2)
        ->fieldCondition('field_status', 'value', 1)
        ->propertyOrderBy('tid', 'DESC')
        ->range(0, 5)

    Entity API

    Describes how to define and manipulate content and configuration entities.


    $cids = \Drupal::entityQuery('comment')
        ->condition('entity_id', $nodeID)
        ->condition('entity_type', 'node')
        ->sort('cid', 'DESC')

    Another example, using the core File entity:


    $fids = Drupal::entityQuery('file')
      ->condition('status', FILE_STATUS_PERMANENT, '<>')
      ->condition('changed', REQUEST_TIME - $age, '<')
      ->range(0, 100)


    Subscribe to Digital