Blog

Link to a node in twig [drupal 8]

Twig is the theme engine in drupal 8 sites. This snippet how to link to nodes correctly, without using preprocess functions to do it.

Blog

Set format of date field in twig using drupal 8

Twig comes with quite some handy functionalities. Date formatting is an example. In this snippet an example of how to show the created date in a drupal 8 time format. 

Blog

Drupal 8 trim body text in twig

Sometimes you need a body text that is trimmed. No need to install contrib modules.

Blog

hook_views_pre_render: add javascript to view in drupal 8

Use global theme javascript only in a few occasions. You should make sure javascript is only used on the right places. This snippet shows you how to load javascript when a specific view is loaded only.

Blog

Create a batch process with interaction in drupal 8 [SOLVED ]

Batch processes give you a hard time when using them for the first time. This module example will handle every aspect of it!

Blog

Uri to image style url [drupal 8]

A much needed functionality is how you get the url of an image style form the uri (f.e. in a node object). This snippets helps you accomplish this.

Blog

How to save meta tags to your node programmatically

When importing content, it is really important you also think about meta tags on your import. Here's how to save them to nodes.

Blog

How to programmatically update an entity reference field in drupal 8

Drupal 8 is becoming more and more API-first based. This means a lot of imports and exports of data will be done. A thing you might face here, is that the updating of entity reference fields is a bit tricky. Here I'll show you how it is done.

Blog

Create paragraphs and attach to node programmatically in drupal 8

Paragraphs give great power to drupal 8. This code will show you how you can add them programmatically, for example when importing stuff.

Blog

Send e-mail with managed file attachment in drupal 8

Sending files attached in e-mails is a necessary feature for a lot of applications. This snippet shows you how to attach a managed file f.e. an invoice to your custom e-mail.

Subscribe to