
$meta_charset = array(‘#tag’ => ‘meta’, ‘#attributes’ => array(‘charset’ => ‘utf-8’)) ĭrupal_add_html_head($meta_charset, ‘meta_charset’) ĭrupal_add_css(‘’, array(‘type’ => ‘external’)) īut now in Drupal 8 and onwards, all is centralized in the #attached property.

You used to do the next steps using different procedural functions: Adding HTML Meta tag: drupal_add_html_head() In this case, you could add your resources in the Drupal 7 way, using some functions. In some occasions, you may need add some resources to your Drupal project, in order to alter the rendering of some And this made me think of a property available in the Drupal arrays that I still write about a littleĭon’t expect a big meditation, just some ideas and tips that I hope will be useful to someone.īut first, let’s start at the beginning (or almost). The answer is simple: in both cases I had to make use of the #attached property, available for use in Drupal’s
#Drupal 9 attach library series
This article is part of a series of posts about Drupal Tips.ġ- Drupal Fast Tips (I) - Using links in Drupal 8Ģ- Drupal Fast Tips (II) - Prefilling fields in formsģ- Drupal Fast Tips (III) - The Magic of ‘#attached’Ĥ- Drupal Fast Tips (IV) - Xdebug, DDEV and Postmanĥ- Drupal Fast Tips (V) - Placing a block by codeĦ- Drupal Fast Tips (VI) - From Arrays to HTMLħ- Drupal Fast Tips (VII) - Link Fields from Twig Okay, but what do the two activities have in common?… Portability to Drupal 8 of a small contrib module, the humans.txt. On the other hand, recently I was preparing some Drupal patches for the (it will be written in Spanish in Medium). Picture from Unsplash, user Masaaki Komori a few days ago, I’m preparing a tutorial about the integration of JavaScript in Drupal that will be released soon
