Skip to main content
Sometimes, while custom coding, it require headers like content-type to be added to the responses by using drupal_add_http_header() in Drupal 7. But it deprecated in 8. Drupal API talking about Symfony object Response to use in order to its replacement. For example, in Drupal 7 drupal_add_http_header('Content-Type', 'text/csv; utf-8'); The equivalent / replacement , in Drupal 8
Dynamically generated CSS and JS Usage / Example In extremely rare and advanced cases, you may have the need to dynamically generate CSS and JS. Like adding CSS/JS from Admin settings based files (Dev, Prod, min etc). In below example will alter library dynamically. First define Lib in MYMODULE.libraries.yml some-lib: header: true js: { type: external, minified: true } Now attach this Lib to site or any section
Fraction Slider is a jQuery plugin which adds a fully customization element slider to your website. Fraction Slider is HTML5 multi-layer and parallax slideshow. Works fine with views fields. Features Multi-Layer slider Parallax Support Similar to Layerslide Installation
While using Drupal Address Field module, When it needs to customize field, its variable returns country as ISO code. Like, if "Pakistan" will return "PK". This funtion will help to convert ISO country code to country name.   <?php $country_iso = $node->field_address['und'][0]['country']; // Example, return "TR" $country = _addressfield_country_options_list($country_iso); print $country; // will print Turkey ?>  
It's really a potential security risk for people new to Drupal or PHP for using PHP Filter code. Some of these listed. Code in your database can not be version controlled and is also harder to find in general later on. Eval()'d code is much slower than something hardcoded in a file. If there is an error somewhere in that code, you will get a very unhelpful error message (error in eval()'d code at line 3) and you might even have go through your database manually to find and fix the error.