Code Examples

Override head title set by Metatag module in Drupal 8

Image by Pexels from Pixabay
Once Drupal's metatag module controls the head title, it is not apparent how to override it programmatically with a custom module or controller, because the Metatag module adds additions to a title like a [site:name], or anything that is set be default in its global settings. The article shows an example of overriding the head title programmatically without modifying theme files.

Send email with an attachment without using contrib modules in Drupal 8

Mail Box
This tutotial provides code example for sending emails with an attachment without using any contrib modules in Drupal 8. We show how to properly include files's content and mime headers into message body which will become an email with an attachment by using hook_mail() and drupal mail manager.