限制 drupal 视图仅显示用户创建的节点

发布于 2024-11-04 08:31:55 字数 146 浏览 1 评论 0原文

我正在使用 drupal 7。我创建了一个视图来显示特定内容类型(例如产品)的节点。查看页面时,我只想显示由用户创建的那些产品(当前显示所有产品)。

我想在不使用 url 过滤器的情况下执行此操作,因此 url 很简单:

/myproducts

I'm using drupal 7. I created a view for displaying nodes of a specific content type (e.g. products). When viewing the page, I want only those products displayed which were created by the user (currently shows all products).

I would like to do it without using a url filter so the url would be simply:

/myproducts

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

自控 2024-11-11 08:31:55

使用过滤器“用户:当前”。如果这不起作用,请尝试建立关系

Use the filter "User: Current". If that doesn't work, try with a relationship

此刻的回忆 2024-11-11 08:31:55

通过高级帮助模块,您可以看到“按当前登录用户过滤内容的示例”:http:// yoursite /help/views/example-filter- by-current-user

那里说:

建立关系

为了能够访问内容的作者,在当前内容类型和用户之间创建关系非常重要。

在右列的“高级”下,选择“关系”旁边的“添加”。

选择内容:作者,然后单击添加并配置关系。保留设置不变,然后单击“应用”(所有显示)。

您现在可以访问与您正在查看的内容相关的用户数据。

过滤视图

现在您需要过滤视图以仅显示当前用户创作的内容。此 > 数据现在可用于内容,因为您已在上面的步骤 > 中创建了关系。

在“过滤条件”旁边,单击“添加”以将新过滤器添加到您的视图中。

通过选择顶部“过滤器”旁边的“用户”来过滤字段列表。由于您创建的关系,您现在拥有比以前更多的 > 字段。

从列表中选择用户:当前,然后单击添加并配置过滤条件。

由于该字段仅因您创建的关系而可见,因此已在关系下选择了作者。这表明您创建的关系正在用于筛选字段。

在“是否是登录的用户”下选择“是”,然后单击“应用”(全部显示)。

如果您创作了博客文章类型的内容,您现在应该在底部的预览部分下看到这些帖子的列表。

保存并保存测试视图

With the Advanced Help module you can see "Example to filter content by the current logged-in user": http:// yoursite /help/views/example-filter-by-current-user

And there said:

Creating the relationship

In order to have access to the author of the content, it is important to create a relationship between the current content type, and users.

Under Advanced in the right column, select add next to Relationships.

Select Content: Author and click on Add and configure relationships. Leave the settings as they are and click on Apply (all displays).

You now have access to the user data related to the content you are viewing.

Filtering the view

Now you need to filter the view to display only content authored by the current user. This >data is now available for the content because you have created the relationship in the step >above.

Next to Filter criteria click on add to add a new filter to your view.

Filter the list of fields by selecting User next to Filter at the top. You now have more >fields than before due to the relationship you created.

Select User: Current from the list and click on Add and configure filter criteria.

Since this field is only visible due to the relationship you created, author will already be selected under Relationship. This shows that the relationship you created is being used for the filter field.

Select Yes under Is the logged in user, and click on Apply (all displays).

If you have authored content of the type Blog Post, you should now see a list of those posts under the preview section at the bottom.

Saving & testing the view

酒与心事 2024-11-11 08:31:55

这是我用来让它发挥作用的。

  1. 在关系下,添加内容:作者
  2. 在上下文关系下,添加用户:身份验证名称和关系:作者(或任何您所说的关系)。

如果您想更加确定,请添加到过滤器:当前用户并添加关系。

Here's what I used to make it work.

  1. Under relationships, add content:author
  2. Under contextual relationship, add user: authentication name and relationship: author (or whatever you called your relationship).

And if you want to be even more sure, add to filter: user current and add relationship.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文