欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

查看曝光过滤器以搜索多个字段

 

据我所知,在drupal 7中没有一个选项,在一个视图中创建一个单独的过滤器,搜索多个字段,而在以前的版本中存在的模块。

使用or运算符很好,但是你在表单中得到多个字段。

添加Global: Populate filters,您可以有一个字段,但视图从不显示任何东西。

有没有任何方式或模块,将使这项工作?

编辑:我没有注意到的是现场操作员。由于某种原因,视图中文本字段的默认运算符是=,而正确的搜索函数需要containshas word我一直在寻找的原因,我不能让它工作近6个月了。哇。什么痛苦。/ facepalm

据我所知,在drupal 7中没有一个选项,在一个视图中创建一个单独的过滤器,搜索多个字段,而在以前的版本中存在的模块。

使用or运算符很好,但是你在表单中得到多个字段。

添加Global: Populate filters,您可以有一个字段,但视图从不显示任何东西。

有没有任何方式或模块,将使这项工作?

编辑:我没有注意到的是现场操作员。由于某种原因,视图中文本字段的默认运算符是=,而正确的搜索函数需要containshas word我一直在寻找的原因,我不能让它工作近6个月了。哇。什么痛苦。/ facepalm

d

正确答案

是的,您可以使用Global: Populate filtersViews过滤器填充模块在单个导出的过滤器中搜索多个字段

检查这个答案

分享改进这个答案
 
2 
我只是把这个标记为答案,但我想我会详细说明实际问题是什么(我已经工作了超过6个月,典型的,我会解决它自己更少不到半小时就粘在栈上)之后 -  合资 在9:33 11月15日'12
 

我知道这个问题已经回答了,但是我认为我会发现有另一个过滤器叫做“搜索:搜索术语”,它基本上模拟了Drupal节点搜索,并搜索整个节点输入的关键字。你不能选择任何字段来专门搜索,我不知道它是否使用“搜索索引”视图模式等,但它的效果非常好。

更多信息:http : //drupal.org/node/680442

分享改进这个答案
 
   
这实际上是最简单的方法,它也很快。尝试不同的方法,这一个是迄今为止最好的。评论时间70 年01  01 原作者Larzan drupal.stackexchange.com/questions/73731/... 评论时间7001  01 原作者: 

在Drupal 7中,你可以使用

Global: Combine fields filter

以获得所需的功能。通过使用它,您可以选择要执行搜索的多个字段。

To my knowledge there hasn't been an option in drupal 7 to create a single exposed filter in a view which searches multiple fields, while in previous versions there existed modules to do just that.

Using the or operators is fine but then you get multiple fields in the form.

Add Global: Populate filters and you can have a single field but then the view never shows anything.

Is there any way or module that will make this work?

Edit: What I didn't notice was the field operators. For some reason the default operator for text fields in views is =, while a proper search function needs contains or has word. I've been looking for the reason I couldn't get it to work for almost 6 months now. Wow. What a pain. /facepalm



正确答案
Yes, you can have multiple fields search in a single exported filter using Global: Populate filtersand Views filter populate module.

Check this answer.

shareimprove this answer
 
2 
I'm just going to mark this as the answer, but I thought I'd elaborate on what the actual problem turned out to be (I've been working on this for over 6 months, typical that I'd solve it myself less than half an hour after sticking it on stack) – J V Nov 15 '12 at 9:33
 

I know this question has been answered already, but thought I'd chime in that there's another filter called "Search: Search terms" which basically emulates the Drupal node search and searches the whole node for the entered keywords. You can't select any fields to specifically search, and I'm not sure if it uses the "Search Index" view mode etc. But it works very well.

More info: http://drupal.org/node/680442

shareimprove this answer
 
   
This is actually the easiest way to go, and it is fast too. Tried different approaches, this one is by far the best. Also described here drupal.stackexchange.com/questions/73731/… – Larzan May 8 '15 at 13:54

In Drupal 7, you can use

Global: Combine fields filter

to get the desired functionality. By using the same, you can select multiple fields on which you want to perform search.


来自  http://drupal.stackexchange.com/questions/50527/views-exposed-filter-to-search-multiple-fields



公开视图中两个字段组合的单个过滤器

我有两个用户配置文件字段“姓氏”和“名字”。我也有一个用户列表视图。我想公开“名称”作为过滤器,可以搜索姓氏和名字。我如何能做这两个字段的组合的单个过滤器?我可以从视图UI创建它吗?

一种可能的方式是创建另一个配置文件字段“Name”,它将隐藏在表单中。在用户保存时,我将两个字段值合并到“名称”字段,然后将其作为过滤器在视图中公开。但是这个解决方案是硬编码,它需要写钩子。

分享改善这个问题
 

正确答案

我终于从溶液我遵循提供的第二个主要解决方案,虽然博主个人使用hook_views_query_alter()

  1. 安装了模块视图过滤器
  2. 添加了两个过滤器“First Name”和“Last Name”(两者都不得公开),并将它们添加到OR过滤器组(Views 3支持此过滤器)。我不得不使用运算符“包含任何单词”的两个字段,否则查询给我没有所需的结果。
  3. 创建了一个过滤器“全局:填充过滤器”,将两个字段添加到此并将其暴露。

这给了我一个快速的解决方案,没有硬编码。
这里是其他有用的参考。

分享改进这个答案
 
   
我不认为你需要使用步骤2 - 我安装了模块,并使用暴露的“全局:组合字段筛选器”。我选择了组合字段设置中的两个字段。评论时间70 年01月01日原作者 :  Laryn - CEDC.org

在我的安装,D7与视图7.x-3.6,您可以添加一个过滤器是“全局:组合字段过滤器”,这将完全按照您的需要,允许用户使用单个过滤器搜索多个字段。

分享改进这个答案
 
   
这应该是接受的答案 -  评论时间70  01  01 原作者

它真的很容易。

  1. 点击添加过滤器。
  2. 选择“全局:组合字段过滤器”
  3. 按照说明进行操作。

谢谢。

分享改进这个答案
 

开箱即用

最简单的方法是使用“搜索字词”过滤器,即视图核心功能它将搜索实体的所有字段并返回结果,无需额外的模块!

  1. 转到您的视图
  2. 添加新的过滤器以进行查看
  3. 选择“搜索:搜索字词”

这是它,没有别的事情(你可能想要暴露它)

它执行得很好。

 

Expose single filter of combination of two fields in views

I have two user profile fields "Last Name" and "First Name". I also have a user list views. I want to expose "Name" as filter which can search for both Last Name and First Name. How can I do single filter of combination of those two fields? Can I create it from views UI?

One possible way is to create another profile field "Name" which will be hidden in the form. On user save, I would combine the two field values into the "Name" field and then expose it as filter in the views. But this solution is hard coding and it needs to write hooks.

 

正确答案
I eventually got a solution from this. I followed the second primary solution offered although the blogger personally used hook_views_query_alter().

  1. installed the module Views filters populate.
  2. added two filters "First Name" and "Last Name" (both must not be exposed) and added them to a OR filter group (Views 3 supports this). I had to use the operator "Contains any word" for both fields, otherwise the query gave me no desired result.
  3. created a filter "Global: populate filters", added the two fields into this and exposed it.

This gave me a quick solution without hard coding.
Here is other helpful reference.

shareimprove this answer
 
   
I don't think you need to use step 2 -- I installed the module and used a "Global: combine fields filter" that was exposed. I selected the two fields within the settings of that combined field. – Laryn - CEDC.org Aug 28 '15 at 14:44

On my installation, D7 with Views 7.x-3.6, you can add a filter that is " Global: Combine fields filter" which will do exactly what you need, allow users to search on multiple fields with a single filter.

shareimprove this answer
 
   
This should be the accepted answer – frazras Apr 7 '16 at 11:19

Its really easy.

  1. Click on Add a filter.
  2. select "Global: Combine fields filter"
  3. Follow the instructions.

Thanks.

shareimprove this answer
 

Works out of the box

The easiest way to go is to use the 'Search Terms' filter which is Views core functionality. It will search through all the fields of the entity and return the result, no extra module necessary!

  1. Go to your View
  2. Add a new filter to view
  3. Select 'Search: Search Terms'

Thats it, nothing else to do (you might want to expose it though)

It performs very well too.

shareimprove this answer
来自  http://drupal.stackexchange.com/questions/42726/expose-single-filter-of-combination-of-two-fields-in...
普通分类: