By Arun AK, 10 September, 2021

Blocks are building blocks of Drupal website. Each content in a Drupal website belongs to one block or other. Blocks can be easily displayed in different part of the webpage using regions in themes.

There are two types of custom blocks in Drupal:

  1. Create using Drupal Graphical User Interface(GUI) system through /admin/structure/block/block-content
  2. Programmatically create based on your requirement

Let's see each method in more detail below.

By Arun AK, 1 May, 2020

Drupal is a popular and best content management system. Even it is more powerful, and sometimes we have to deal with a tough time if we are not maintaining it well.

Here we see one of the issues that can happen in Drupal 8 if we do not correctly uninstall module before it removes from the file system. Your site might be working correctly on the production server, and the issues can arise after you move your site into a new server or after setup your local dev environment.

By Arun AK, 10 November, 2019

Drupal VM is a virtual machine built with Ansible. Drupal VM makes Drupal development easy and helps the developer to start working on a fully configured environment in his local computer.

By Arun AK, 6 November, 2019

In Drupal 8 we can use the Metatag module to add metatag to the pages. This module supports almost all the meta tags. Also, in case if you could not find a required meta tag in this module, it is easy to create a new meta tag by extending the 'MetaNameBase' class provided by the Metatag module.

By Arun AK, 5 November, 2019

Sometimes you may need to alter a template that is provided by a module. Usually, you will be able to override the template by copy it into your themes template directory.

But in a case such as Drupal multi-site setup with a single code base and shared the theme, it is difficult to alter template specifically for a particular website. Then if you are doing it using a module you will be able to achieve for a particular website.

The hook hook_theme_registry_alter() will help to alter the template path for a particular theme function.

By Arun AK, 7 January, 2018

During development it is important to make sure not exploiting any kind of security issues. Here we are going to see how can secure server details without showing to public users while handling an exception.

In this example we have a custom menu callback which will process the argument which we are passing with the url. We will pass media id(mid) with the url and it will force prompt download corresponding the media file.

Define custom menu callback: custom_module.routing.yml

By Arun AK, 18 June, 2017

In Drupal 8 theming and templating are quite different than in Drupal 7. But D8 is providing very seamless options and lots of addons to make theming easy.

One of the power tool which helps to debugging and theming is Kint. Kint is a powerful and modern PHP debugging tool. Kint wisely detects what kind of data is being displayed and provides nicely formated data.

By Arun AK, 3 June, 2017

Twig is a flexible template engine for PHP. In Drupal Twig is using as default template engine. Twig is flexible, fast, and secure. Here we are going to discuss how we can integrate twig in Drupal 8. We will go through how to use twig template and how we can add new template for a block.