Drupal 9
How you build a Drupal site will greatly depend on your personal preference or the preference of your boss/client.
A favourite debate between other developers and myself is if it's better to:
start with a pre-made theme and then fight it to remove all of the things you don't want it to do, or…
To install a module you just run composer require drupal/<modulename> i.e. composer require drupal/token
You can also specify a version composer require 'drupal/<modulename>:<version> i.e. composer require 'drupal/token:^1.5'
Note the quotes when specifying a version.
Typical…
Drupal 9 modules can be updated with Composer by running the following at the command line in the 'root' level where your sites composer.lock file is located.
composer outdated "drupal/*"
This will return any Drupal modules that are out of date and the suggested version. An example is as follows:…
Drupal 9 is designed to be updated with Composer where previous versions allowed manual uploading of files or by using Drush. This is an easy process and can be done running the following at the command line in the 'root' level where your sites composer.lock file is located.
composer outdated "…
I'm using XAMPP to build a Drupal 9 project so I start here C:\xampp\htdocs and create a folder for my D9 site, i.e. 'myd9site'. Using XAMPP's Shell command tool, navigate to the 'htdocs' folder and run:
composer create-project --no-install drupal/recommended-project myd9site
This only loads the…
Image styles within Drupal are one of the things you take for granted, yet are one of Drupal's best tools. A user with CMS access can create an 'Image Style' which can be used on a content type display page or within a 'View', all without any coding.
However, sometime you have to add an image style…
There are a few basic things a developer needs to do in a custom module.... node creation is top of my list.This code is within a controller that is part of a custom module. I won't explain how to build the module but this code is within a file called ReportController.php.
The basic file code is:…
There are a few basic things a developer needs to do in a custom module.... SELECT, INSERT and DELETE queries are top of my list and this article demonstrates a few examples of SELECT and INSERT queries.This code is within a controller that is part of a custom module. I won't explain how to build…
Whilst converting a D7 site to D9 I came across some SQL in the node.tpl.php template. This clearly shouldn't be in the template and the poor developer had added a comment saying as much, but was clearly under pressure and maybe not as experienced as they needed to be.So, with D9 using TWIG I…
Sometimes you need to get a field in the page.html.twig template. The template hierarchy suggests that node values (fields) should be rendered in the node.html.twig template and page.html.twig is the parent template that should be dealing with regions etc.
The solution is use THEME_preprocess_page…