简体   繁体   English

Drupal 8 REST查看分类路径

[英]Drupal 8 REST View Taxonomy path

I have created a view in Drupal 8 with a REST output. 我在Drupal 8中使用REST输出创建了一个视图。 The view is configured to show taxonomy terms of a certain vocabulary. 该视图配置为显示特定词汇的分类术语。 I have configured the view to use the "Fields" display so that I can choose which fields are shown. 我已将视图配置为使用“字段”显示,以便可以选择显示哪些字段。

The problem is that I can't find a way to show the alias path for a taxonomy term. 问题是我找不到一种方法来显示分类术语的别名路径。 This value is not present under a taxonomy term. 在分类术语下不存在此值。 It is present under "Content", but then the link goes to content inside the taxonomy. 它显示在“内容”下,但随后链接指向分类法内的内容。 When I choose "Taxonomy term: Link to Taxonomy term", it does show the correct link. 当我选择“分类术语:分类术语的链接”时,它会显示正确的链接。 But that field also generates complete html (<a> tag) and I want just the link value. 但是该字段还会生成完整的html(<a>标记),我只需要链接值。

There used to be a module called "Views Term Path", but that module does not support Drupal 8. 曾经有一个名为“视图术语路径”的模块,但是该模块不支持Drupal 8。

Same problem, I solved it by doing: 同样的问题,我通过执行以下操作解决了该问题:

  • Add a field "Taxonomy term: Term ID [hidden]" (make it hidden or not) 添加字段“分类术语:术语ID [隐藏]”(使其隐藏或不隐藏)
  • Ensure that this field is in first position (if not, rearrange the fields order) 确保此字段位于第一位置(如果不在,请重新排列字段顺序)
  • Add a field "Global: Custom text" 添加一个字段“全局:自定义文本”
  • Put "{{ path('entity.taxonomy_term.canonical', {'taxonomy_term': tid}) }}" (thx @steven) in the "Text" section in the settings modal of this field. 将“ {{path('entity.taxonomy_term.canonical',{'taxonomy_term':tid})}}”(thx @steven)放在此字段设置模式的“文本”部分中。

Original response: https://drupal.stackexchange.com/a/244092/78476 原始回复: https : //drupal.stackexchange.com/a/244092/78476

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM