Drupal 8 Twig cheat sheet


To check if a field has a value, check to see if the 0 array item is populated. Simply checking if content.field_name is truthy will not work since that variable will be defined even if the field is empty.

How to add Custom Permissions to your Drupal 8 module

In order to add custom permissions we used to use hook_permission in Drupal 7, however in Drupal 8 this is done through the yourmodulename.permissions.yml file

Here is an example of what the file should look like

administer commerce_amazon_slider:
  title: 'Administer Commerce Amazon Slider'
  description: 'View, edit and update Commerce Amazon Slider configurations'