PHP Class using StringTranslationTrait
StringTranslationTrait allow to get t() and formatPlural() methods
Example:use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
class MyClass {
StringTranslationTrait allow to get t() and formatPlural() methods
Example:use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
class MyClass {
Method 1 : Form hook_page_attachments
In this example, we will use a field to get tags list, the number of tags dynamic.
Note : On drupal the best practice is use drupal behaviors but not JS or Jquery codes such as:
<button onclick='myFunction()'>Click</button>
Note : It's not possible to read the current headers. You could make another request to the same URL and read its headers, but there is no guarantee that the headers are exactly equal to the current.
Note : Following examples are tested on FireFox Version 52.
Method 1 . Press F12 and click on "Console"
Method 2 . Press Ctrl + Shift + K
Example :
For example in the top window (Parent): (the_iframe.contentWindow.postMessage('data', 'domain');
)
Drupal behaviors allow to execute javascpts in particular context and / or pass data from drupal to client side java script.
Example : Execute JS only in the front page.
This Script run whin the body
tag contains class='front'
.modal-backdrop {
  background-color: transparent;
}