如何在 Twig drupal 中连接 url('<front>') + 字符串
How to concatenate url('<front>') + string in Twig drupal
我正在尝试 select 一个等于 drupal html.html.twig 中的 (http://myweb/app) 的路径。
为此,我使用 URL,但是当尝试连接一个数组(url ('<front>')
与字符串 returns ArrayString)时,显然这是错误的。
{% set url_app_front = url('<front>') %}
{% set url_app = url_app_front ~ 'app' %}
Arrayapp
明明url('<front>')
是一个数组,但是returns干净的#Markup是http://myweb/。我试过 select 但是...不知道怎么做。
{{ url('<front>').markup }}
我正在寻找的是...
{% set url_app = url('<front>') ~ 'app' %}
{% set url = url('<current>') %}
{% if '{{ url_app }}' in url|render|render %}
到selecthttp://myweb/app
如果有其他方法可以实现,我也愿意拜读
我们必须使用 render_var()
将此数组转换为字符串(感谢#markup)
我在 https://drupal.stackexchange.com/questions/243648/concatenate-url-in-twig 得到了它(我很抱歉没有先看那里)
{% set url_app = render_var(url('<front>')) ~ 'app' %}
{% set url = url('<current>') %}
{% if url_app in url|render|render %}
....
{% endif %}
我正在尝试 select 一个等于 drupal html.html.twig 中的 (http://myweb/app) 的路径。
为此,我使用 URL,但是当尝试连接一个数组(url ('<front>')
与字符串 returns ArrayString)时,显然这是错误的。
{% set url_app_front = url('<front>') %}
{% set url_app = url_app_front ~ 'app' %}
Arrayapp
明明url('<front>')
是一个数组,但是returns干净的#Markup是http://myweb/。我试过 select 但是...不知道怎么做。
{{ url('<front>').markup }}
我正在寻找的是...
{% set url_app = url('<front>') ~ 'app' %}
{% set url = url('<current>') %}
{% if '{{ url_app }}' in url|render|render %}
到selecthttp://myweb/app
如果有其他方法可以实现,我也愿意拜读
我们必须使用 render_var()
我在 https://drupal.stackexchange.com/questions/243648/concatenate-url-in-twig 得到了它(我很抱歉没有先看那里)
{% set url_app = render_var(url('<front>')) ~ 'app' %}
{% set url = url('<current>') %}
{% if url_app in url|render|render %}
....
{% endif %}