【问题标题】:How to print url of blog tags in drupal如何在drupal中打印博客标签的url
【发布时间】:2021-09-23 13:15:24
【问题描述】:

如何在 Drupal 中打印博客标签的 url 别名? uri.value 不工作

{% for item in node.field_tags %}
 {{ item.entity.uri.value }} {{ item.entity.name.value }}
{% endfor %}

{{ item.entity.uri.value }} # this isn't working

【问题讨论】:

  • 你的“uri”字段的机器名是什么?是field_uri吗?
  • 我要打印标签的url别名

标签: url drupal


【解决方案1】:

您可以使用下面的path() 函数来打印标签的网址别名:

{% for item in node.field_tags %}
  {{ path('entity.taxonomy_term.canonical', { 'taxonomy_term': item.entity.id() }) }}
{% endfor %}

或者url()如果你想要一个绝对网址:

{% for item in node.field_tags %}
  {{ url('entity.taxonomy_term.canonical', { 'taxonomy_term': item.entity.id() }) }}
{% endfor %}

【讨论】:

    猜你喜欢
    • 2012-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多