Hello please tell me, I started using a TWIG template, I just don’t understand how to convert such entry
if (isset ($ _ get ['hash']) & amp; & amp;! empty ($ _ Get ['Hash '])) {
$ hash = $ _get ['hash'];
}
Tell me please. How to work in twig with global variables.
Answer 1, Authority 100%
Access to the global variable can be obtained like this:
$ loader = new twig_loader_filesystem ('templates');
$ twig = new twig_environment ($ Loader);
$ twig- & gt; addglobal ('get', $ _get); // Now GET in the template will correspond $ _Get
Check:
{% if get.hash is defined and get.hash is not empty%}
{% set hash = get.hash%}
{% endif%}