S
S
semki0962017-07-30 20:03:44
Drupal
semki096, 2017-07-30 20:03:44

Why doesn't TWIG see my variable?

Drupal8. I print the current URL and this code works {{ url('<current>') }}
Now I want to split the url and get part of it, and it doesn't work

{% set my_url = url('<current>')|split('/') %}{{ my_url[2] }}
Why does the twig display url('') in the first case and not in the second?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
afi13, 2017-07-31
@semki096

It is better to move such logic to hook_preprocess() and use a ready-made variable in the twig.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question