[英]Convert rows to columns using Twig - D8
I have a content type "Awards" that has data structured as below:我有一个内容类型“奖项”,其数据结构如下:
I want to group this data as below:我想将这些数据分组如下:
Want to group them on a "State" basis.想要在“状态”的基础上对它们进行分组。 So when I click on mysite.com/TXawards, it should show data grouped as below:
所以当我点击 mysite.com/TXawards 时,它应该显示如下分组的数据:
Similarly "/FLaward" page should show data grouped as above.同样,“/FLaward”页面应显示如上分组的数据。 I don't have a view created yet but the content type with data is ready.
我还没有创建视图,但包含数据的内容类型已准备就绪。 What would be the best way to achieve this?
实现这一目标的最佳方法是什么? I was thinking to use a contextual filter but I click the link "/TXawards" which is hardcoded on a page.
我正在考虑使用上下文过滤器,但我单击了页面上硬编码的链接“/TXawards”。 Any help on how to group this data?
关于如何对这些数据进行分组的任何帮助? Thanks
谢谢
UPDATE : I created a"Table" styled view and grouped the rows by Type and State. The view output looks as below.更新:我创建了一个“表格”样式的视图,并按类型和 State 对行进行了分组。视图 output 如下所示。
Can someone help with twigging this output to 2 column format pls?有人可以帮助将此 output 转换为 2 列格式吗?
so this answer that I have doesn't go about transposing your table using the twig templates.所以我的这个答案不是 go 关于使用 twig 模板转置您的表格。 What this does is just give you the data in the direct format from Views and then you can style and format it however you'd like.
这样做只是为您提供来自视图的直接格式的数据,然后您可以根据自己的喜好设置样式和格式。
Since I don't have your fields or project I can't really give you a view export, however I can walk you through a few steps to set it up.由于我没有您的字段或项目,因此我无法真正为您提供视图导出,但我可以引导您完成几个步骤来进行设置。
EDIT: I figured that I might as well toss in the export of the mock-up view I made to make these screenshots. Also, this concept should be applicable for Drupal 7-9, but the export linked may only work for 9.x
Export of Drupal v9.3.12 View that was built as concept for answer.导出 Drupal v9.3.12 作为答案概念构建的视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.