简体   繁体   English

通过将视图字段与URL术语匹配来过滤Drupal View结果

[英]Filter a Drupal View result by matching a view field to a URL term

I have a content type called "Post" which contains two fields: 我有一个名为“ Post”的内容类型,其中包含两个字段:

1) title 2) username 1)标题2)用户名

I created a View which creates a block that gathers all Posts. 我创建了一个视图,该视图创建了一个收集所有帖子的块。 The block will reside on a user's account page, wherein the URL will always be: www.mysite.com/user/username 该块将驻留在用户的帐户页面上,其中URL始终为:www.mysite.com/user/username

How can I filter that block to only show the results where the username field matches the second term in the URL? 如何过滤该块以仅显示用户名字段与URL中第二个词匹配的结果?

Thanks! 谢谢!

Use contextual filter in views and set raw value as second argument from the url (here second argument will be username). 在视图中使用上下文过滤器,并将原始值设置为url中的第二个参数(此处第二个参数为用户名)。

Answered by @manikandankannan at https://drupal.stackexchange.com/questions/187686/filter-a-view-result-by-matching-a-view-field-to-a-url-term Thanks! @manikandankannan在https://drupal.stackexchange.com/questions/187686/filter-a-view-result-by-matching-a-view-field-to-a-url-term回答谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM