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.

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.

Disable block caching in drupal 8

When creating custom blocks, sometimes you need to make sure the block is never cached f.e. when including dynamic links. 

Prevent a controller from being cached in drupal

How to prevent your controller from being cached by drupal.

Add a direct link to the main menu edit form in the drupal toolbar

When optimizing your cms for webmasters, you should always install the menu_admin_per_menu module to make sure your webmaster doesn't get access to non-related menus.

Gzip static assets for drupal in NGINX

A great way to improve your google PageSpeed score is to add gzip compression to your nginx recipe.

Delete an entity reference field programmatically

I found this code useful to delete a value saved as an entity reference.

Adding html to a views header programmatically

Learns you how to put messages on top of a view

Subscribe to Drupal