限制 drupal 视图仅显示用户创建的节点
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用过滤器“用户:当前”。如果这不起作用,请尝试建立关系
Use the filter "User: Current". If that doesn't work, try with a relationship
通过高级帮助模块,您可以看到“按当前登录用户过滤内容的示例”: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:
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.
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.
这是我用来让它发挥作用的。
如果您想更加确定,请添加到过滤器:当前用户并添加关系。
Here's what I used to make it work.
And if you want to be even more sure, add to filter: user current and add relationship.