drupal-8 - Drupal 8 基于当前用户的上下文过滤器

标签 drupal-8 drupal-views drupal-contextual-filters drupal-views-relationship

不知怎的,我不明白。

我创建了组织分类法。然后,我向我的用户帐户添加了一个自定义必填字段,称为“组织”。我想创建一个 View ,其中当前登录的用户只能看到与当前登录的用户属于同一组织的人员列表,而看不到其他人。

我已经很好地创建了 View ,并且用户列表看起来很好,但我无法获得过滤和关系来仅向我显示与当前登录用户属于同一组织的用户。

我可以在大约 2 秒内用 SQL 完成此操作,但由于某种原因,我不知道如何在 Drupal 界面中完成此操作。

我正在运行 Drupal 8。

最佳答案

  1. 添加上下文过滤器用户 ID(以获取当前用户) enter image description here enter image description here

  2. 添加关系从 field_organization 引用的分类术语(以获取当前用户引用的分类术语) enter image description here

  3. 使用 field_organization 添加关系用户(让用户在第 2 步引用组织分类法) enter image description here

  4. 将所有字段的关系更改为field_organization enter image description here

  5. 如果您想从结果中排除当前用户,请添加另一个具有 field_organization 关系的上下文过滤器 User ID enter image description here 请记住向下滚动并选中排除 enter image description here

关于drupal-8 - Drupal 8 基于当前用户的上下文过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67642679/

相关文章:

drupal - 如何使用 Drupal 8 设置 CORS

drupal - 向 Drupal 上的 View 添加排序?

drupal - 查看: Exclude nodes that have the same taxonomy term id(s) as current node

Drupal 8 根据当前路线更改菜单链接

Drupal 8 : Video Embed Field library load order for colorbox responsive video

php - Drupal Redis 模块没有连接到 PHP-Redis

drupal - 将 drupal View 限制为仅显示用户创建的节点

drupal - 通过服务端点将上下文过滤器参数传递给 View

javascript - 在 Chrome 中,img 元素的 currentSrc 有时为空。我怎样才能防止这种情况?

mysql - 无法使用 View 模块创建 View