Drupal

Blog

Create forum topic programmatically in drupal 8

The forum module is a core module that was rewritten for drupal 8. In this snippet I show you how to create forum topics programmatically.

Blog

Clear specific cache in drupal 8

Drupal's default caching mechanism is to clear "all" cache. This is rather inefficiënt. There are options to clear specific caches only, here's how.

Blog

A default .gitignore file for drupal 8

This example might help you setting up default installations.

Blog

Validate numeric url parameter for controller using regex in drupal 8

The routing system that drupal 8 offers is flexible in terms of validation. It is possible to validate your route against some typical regex lines.

Blog

Disable caching on a drupal 8 page controller

Caching in drupal 8 is quite nifty, here's a snippet on how to completely disable caching in your controller.

Blog

Caching in drupal 8 & 9 explained [video & code]

In this video I discuss block caching in drupal 8 & 9. It is quite radically different from drupal 7. I discuss cache tags, cache context and cache max-age.

Blog

Nid to url in twig [Drupal 8]

What if you have to link to a specific url in in twig, but you only have the nid? Moreover, it is good practice to use the id and not a hardcored url. Here's what you should use:

Blog

drupal 8: image field to image style programmatically

Helper snippet to render images with an image style in drupal 8

Blog

Create string translations programmatically in drupal 8

String translations are always a bit a pain in the ass for drupal. Luckily, in drupal 8 the function is rather easy.

Blog

Delete all users of a role in drupal 8

Snippet on how to remove all users with a certain role in drupal.

Subscribe to Drupal