Blog

How to "composer require" Github package

Sometime you would want to require a module or library from Github instead some packagist or drupal.org. Here's how you would do this.

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.

Blog

Delete all menu links of a menu programmatically in drupal 8

I play a lot with importing and exporting content lately. When I remove content, the created menu items need to be removed automatically. Here's a snippet on how to delete all links in a menu.

Blog

Create a menu link with html markup in drupal 8 (menu plugin tutorial)

Goodbye preprocess functions! Welcome to drupal 8. We use a nice plug-in to get control over our menu item and to show html inside the title. In this case we show a counter of the amount of messages a user has.

Blog

Format created date of custom entity in drupal 8 [Solved]

Some parts of custom entities seem different from nodes, but mostly they aren't. Small snippet for showing a created date of a custom entity in a controller

Blog

Fix "The provided host name is not valid for this server" error of drupal 8

When installing drupal 8, or moving to production one could see this error. The fix is extremely simple. 

Subscribe to