如何打印组 ID

How to print the group ID

我已经在 Drupal 8 上安装了 group module :

如果我在组的 twig 中添加代码 {{ group.id }},它不会显示 ID。
如何在twig中打印组ID?

组 ID 将是一个 FieldItemList 对象,不能直接打印。因此,您将需要使用 {{ group.id.value }}。类似于 this answer.

你没有报告 Twig 错误这一事实向我表明,更改没有反映在前端网站上。尝试清除缓存。您可能想阅读 Debugging Twig Templates.