Drupal

Backup Drupal Sites using Backup and Migrate Module

Backup is an essential aspect for every site but often overlooked. Backup seems time-consuming and unnecessary, but when things happen, it can be a life saver freeing you from unexpected damage. It is a question of how backups can be made quickly, preferably automatically, without taking too much time. In addition, it is also essential to make sure when backups are restored, it works reliably as expected without surprises.

In this tutorial, we introduce a module that helps to provide such a solution.

The Backup and Migrate module can backup the database and files of a Drupal site. The module also provides a restore operation of the backups when needed. It can be easily installed in a Drupal site, and it is free. With this module, the authorized user can perform backup manually or automatically. Backups can flexibly include only the database or user files, or both.

When operated manually, backups can be downloaded immediately in compressed file format, or stored in a safe location in the server. When automatic operation is preferred, it can be scheduled, and the backed up files in compressed format will be stored in the server. The site can be taken offline with a notification message during the backup procedure, and return to normal after it’s completed.

Remember you should never rely entirely on a single backup solution. Things can still go wrong. The backup and restoration process may fail for many different reasons. It’s good to have a second backup system, such as at the server hosting level.

How to Host and Deploy Drupal Sites using Cloudways

Cloudways is a managed cloud hosting provider which allows you to host and deploy Drupal sites on popular cloud platforms. They don’t host your site, instead you choose a cloud provider, i.e., DigitalOcean, Linode, AWS and so on.

The benefit of using Cloudways is that you can start on a cheap server and upgrade as needed. You get the same features if you spend $20 or $100 per month. As your site gets more traffic you can scale up to a faster server.

The server provisioning and application management is all done via the Cloudways platform. For example, if you use DigitalOcean, you won’t have to create a separate account to manage the server. You can do everything via Cloudways platform.

The servers come configured with PHP, Apache, MariaDB, Varnish, Redis (uninstalled by default) and so on.

Once provisioned you’ll be able to host an unlimited number of Drupal sites on a single server. You’ll need to make sure your server has enough resources, i.e., RAM and CPU.

Other hosting platforms charge per site and traffic. Cloudways only charger per server and you can install as many websites as the server and bandwidth can handle.

In this tutorial, you’ll learn how to install and deploy a Drupal site on Cloudways.

We’ll cover how to install and run Drupal in two ways:

  • How to manually install Drupal via SSH
  • How to Deploy Drupal using GitHub

Cloudways doesn’t have a one-click install for Drupal. You will need to be comfortable with Composer and using SSH to get into a server. If you want to deploy your Drupal site via Git then you’ll need to be comfortable using GitHub.

How to Bulk Delete Content in Drupal

This tutorial will show you the various ways of batch deleting content inside Drupal. You may want to delete content if you’re doing the following:

  • You want to work on a clone of a Drupal site but delete some or all of its content.
  • You want to clean up your Drupal database and delete some old content
  • You just want to batch delete content for any other reason.

There are different ways this can be achieved. We will cover the following ways:

Select Taxonomy Terms Using Autocomplete Deluxe Module in Drupal

Autocomplete is often used in taxonomy fields, such as the tags field. It helps users locate previous taxonomy terms by displaying a drop-down selection list according to what they are typing. If multiple entries are allowed, it is often separated by commas.

This module uses the jQuery UI autocomplete, implements a taxonomy widget and provides a result for multiple selections similar to the Chosen module, but without downloading a plugin.

How to Display Errors in Drupal

Have you seen an error message in a Drupal site like this?

When you are building or modifying a Drupal site, the error above can sometimes appear and catch us in unexpected situations, but there is nothing much you can do. “Try again later” is not going to help. What will you do?

There is not much you can do about it, because there is not enough information to go further. By default, Drupal is configured not to display error messages. To find out what caused the errors, the error message display options require to be turned on first.

In this tutorial, you’ll learn how to turn on error display to help you debug.

WARNING: It’s important not to display error messages on a production site. The error messages could display sensitive information such as paths or server level user accounts.

Conditionally Display View Fields using Views Conditional in Drupal

The View Conditional module is helpful if you want to display custom text depending on other field values in the View. It can be used to conditionally hide field values based on other View fields.

The module allows you to add a custom “conditional field” to the View, just like any other View field. Then you can use this field to customize the output based on the values of other fields. If this sounds confusing, it will become much clearer as we walk through a real example in this tutorial.

A common use case is if you have a View table and you want to change the content of a column depending on the value of another View field. We will demonstrate this now.

Open Webforms using Dialog Box in Drupal

Webform comes with an option of displaying a form in a pop-up Dialog box, but is not enabled by default. With this option, a webform can pop-up on the screen when clicking on a link. Users can stay on the same page while filling in the form.

In this tutorial, you’ll learn how to enable and configure dialog box pop-ups in Webform.

How to Print Variables using Devel and Kint in Drupal

As a Drupal developer, you will often want to inspect variables in your modules or themes to view the actual values. PHP has default functions such as var_dump() and print_r() that will print all the information but it’s not very intuitive nor printed in an easy to understand way. In most cases, it prints too much information and it can be time-consuming to find the variable you actually want by filtering through all the arrays and methods.

Using Devel and the Devel Kint Extras modules, you can print variables in a more user-friendly way.

This tutorial will walk through how to set up these modules so you can print variables in PHP and Twig using Kint.

Add Autocomplete Search Results to Text Fields in Drupal

Search is an important function in almost every site. There is a simple feature which we can implement to improve user experience, and that is ‘search autocomplete’.

Autocomplete means ‘predictive text’, and it is a feature in which the system predicts the rest of a word a user is typing.

It provides suggestions of words to users while typing, and speeds up the human-computer interaction. It can work well particularly in search because the list of suggested words will come directly from controlled keywords from the system itself.

It is also helpful in situations where long words or hard-to-spell terminologies are involved.

In this tutorial, we’ll learn how to install and configure the Search Autocomplete module in Drupal. The module provides an easy way to convert any text field into an autocomplete field.