getting entity field values programmatically is easy, but check this out.
Today I have a small helper module to share with you. A small pain in the ass is that the sending of e-mails requires a bit too much code. More specifically sometimes you would like to send simple alerts to webmasters. This helper module helps you with it.
One of the biggest flaws in drupal is the disability to do something easy as sending html emails out-of-the-box. In drupal 8 it is already slightly better, but you would need to know some things.
Config entities are new in drupal 8. The differ a bit from content entities. Here a snippet on how to get the value of a field programmatically.
Drupal set message was deprecated in Drupal 8.5 and will be removed before Drupal 9. Time for a roundup of this new API and how to use it.
The way of handling javascript and css is different from drupal 7. This snippet shows how to do it.
When you give users the permission to administer users, there is a security implication in that users with this permission can add the role 'administrator' role to any user.

Block access is a powerful way to show or hide content in some contexts. Instead of using contrib modules, this is very easy in small pieces of custom code. The following code prevents access to a block based on a subscription field in the user object.

The following code shows how to create a custom form in the drupal back-end and how to save custom config defined in your custom module. Powerful stuff and very flexible.

You can update custom config with a settings form you build. 
In a custom module *custom_mailing* add a file called *custom_mailing.routing.yml* add the following route:

Custom formatters are great to get precise control over your field output. But I ran into something difficult when trying to output the description of a file field.
In a node teaser or full view mode it is for front-end purposes needed to know if an image is available. This snippet takes care of it.
When using twig, sometimes you would like to know whether the view has results or not. This snippet shows you how.
How do you get the base url of a drupal 8 website programmatically?
Little snippet to show how to query nodes with f.e. condition of "1 week ago".
In drupal 8 you can experience your datefields showing up in English instead of in the language of your website. This fixes it.
By default you get to see a strange screen saying how long your are a member. It is good practice to auto-redirect users on login to the /admin/content page. This snippet does the trick.
A composer update of your drupal can override changes to your htaccess file. With this snippet you can patch it correctly.
It is seen as a bad practice to add complete libraries to your theme in drupal 8. You should add these as packages to your composer file.
The page callback system in drupal 8 is considerably different from drupal 7. This snippet shows you how to show a title depending on your language.
The typical 'from' 'to' datefields are not quite good for usability. With the following snippet you can change the labels.
Snippet to create a link with a class programmatically.
When editing notes, an often mentioned problem of webmasters is the lack of preview of their text. With this snipped you can embed the css of your theme in CKEditor, which makes it much more visible towards your webmasters.
Drupal 8 will standard give the term name as page title on /taxonomy/term/term-foo. I want to alter this so it says "Items tagged with Term foo". 
How can you query for nodes, terms etc of a drupal 7 website from your drupal 8 website? 
A frustrating thing for webmasters is often that they cannot see the eventual lay-out of text styling in their CKEditor. This snippet fixes this issue.
This module explains how you can add custom scripts inside your controllers. Something that is useful for things like e-commerce and advertising.
This little tip adds just that extra good feeling for your webmasters. And a click less to the "Add content" page.
The following snippet makes you format a date field inside a twig file.
You often need to get the current language in your Drupal 8 custom modules or theme. Here's how to get it.
Sometimes you want to import specific config files, out of your main config library. Here's a drush snippet which does exactly that.
When a drupal site has different domains for its language, difficulties can arise when developing locally. With this snippet, you override your language settings, so prefixes are used instead of domains.
Always try to use the core functions for linking inside custom formatters or modules. The following snippet allows html inside the link text.
I personally like using the drupal menu block module. It allows for quick creation of submenu's. The following patch fixes a bug that keeps showing regions, even when there are no subitems in the menu block.
$date = strtotime($importObject->created_at); // which is a date format
$node->set('created', $date);
// $node->save(); etc


When saving nodes programmatically, you probably want to set the body to accept html. it is important to set the input format, so html is accepted.
This is quite a nice feature to run database operations on your website. Found some wrong implementations so I thought I'd share it here.

From time to time it comes in quite handy to import configuration from other websites into yours. You site uuid is unique though, with the following snippet you get yours.

drush config-get "" uuid

To set the uuid in drush:

drush cset uuid 9b13adbf-0da5-4937-a731-xxxxxxxxxxx -y

A typical setup is one where you would redirect all non www and http requests to I prefer to keep my .htaccess file in version control also. With the following snippet, I get it the way I want it.

The following snippet will return your langcode f.e. 'en', 'nl', etc. Use the following code:

// Get current language code
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();


I started using an automated script for my drupal installation, which will generate an admin user. But, after installation I have to edit the password.
I like a good user interface for webmasters, so a clear menu path is necessary. For the admin toolbar dropdowns, I usually create subitems programmatically. 
While there are many ways to debug your errors, sometimes just seeing the full errors in your screen works best.
I recently had an issue with ckeditor inside pop-ups (modals) in drupal 8. This snippet is the solution to it.
I recently found out a bug I wasn't aware of. My default text format wasn't saved on a body field. I attached a snippet to fix this.
I've had some difficulties loading a list of translated terms. More in particular I didn't want to show the untranslated terms, but ONLY the ones that were already translated in the current language