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

这里的技术是共享的

You are here

drupal 6 views filter form 条件 使用 or 有大用

我使用的 

方案3: Option 3 见 见 /node-admin/6115

实现过滤器OR运算符

 
您正在查看的wiki页面。欢迎您加入该群,然后编辑它大胆!

问题

我想查看查询,以捕获可能有分类术语的下列三种组合节点:

A,B 
A,C 
,A,B,C

由此产生的逻辑应该返回true时,“(B或C)和”

最近我一直能够得到与视图是结果如下:

  1. 返回(A,B)和(A,B,C)的组合
  2. 返回(A,C)和(A,B,C)的组合

任何人都可以指出的浏览器应该如何配置我需要的结果吗?为查看教程似乎缺乏过滤器是如何运作的一个合理的解释。

使用视图

由于意见2.1,或者在过滤器操作不被支持。然而这是一个计划的功能,这将使它的方式进入2次在一些点。

在平均时间,有几种选择。需要注意的是没有人可以考虑向前兼容:

选项1:查看或过滤器

视图或过滤器可以让你做到这一点没有任何编程,在你的意见中界定的替代品插入额外的过滤器。

而在一些生产基地已被使用,这个过滤器仍处于实验因为它没有经过充分的测试。

选项2:查看修改查询过滤器

如果你是一个程序员,要修改自己直接查询,而无需实现一个模块来做到这一点,您可以使用浏览修改查询过滤器,它可以让你在视图建设过程中添加额外的代码。

提示:在过滤器,通过输出$启动该或$这个- >查询,然后显示使用次数的结果
修改查询字段。编写代码来实现更改之前研究结构。

方案3:实现自己的代码/过滤器

如果你不能让浏览用户界面做你想做的,你可以随时退回到hook_views_query_alter,或实现自己的滤波模块,并修改了逻辑分析,你喜欢的方式。

提示:只要里面hook_views_query_alter您的自定义模块中打印出使用查询print_(),然后修改查询(这是按引用传递),你想要什么。/node-admin/6115

 

Achieving an OR operator in Filters

 

 

You are viewing a wiki page. You are welcome to join the group and then edit it.Be bold!

Problem

I want a View query to capture nodes that may have the following three combinations of taxonomy terms:

a, b
a, c
a, b, c

The resulting logic should return true when "(b OR c) AND a"

The closest I have been able to get with Views are the following results:

  1. Returns (a, b) and (a, b, c) combinations
  2. Returns (a, c) and (a, b, c) combinations

Can anyone point out how Views filters should be configured for the results I need? The tutorials for Views seem to be lacking a reasonable explanation of how filters operate.

Using Views

As of Views 2.1, OR operations on filters are not supported. This is, however, a planned feature that will make it's way into Views 2 at some point.

In the mean time, there are several options. Note that none of them can be considered forward compatible :

Option 1 : Views Or Filter

The Views Or filter lets you do this without any programing, by inserting extra filters in your views that delimit alternatives.

While already used in some production sites, this filter is still considered experimental as it has not undergone sufficient testing.

Option 2 : Views Modify Query filter

If you are a programmer and want to modify the query yourself directly without having to implement a module to do it, you can use the Views Modify Query filter which allows you to add extra code in the view building process.

Hint : In the filter, start by output $this or $this->query and then display the result using the Views
Modify Query field. Study the structures before writing code to implement your changes.

Option 3 : Implement your own code/filter

If you can't get the Views UI to do what you want, you can always fall back to hook_views_query_alter, or implement your own filter module, and modify the logic the way you like.

Hint: Just print out the query using print_() in your custom module inside hook_views_query_alter and then modify the query (which is passed by reference) to what you want.  见 /node-admin/6115

来自  https://groups.drupal.org/node/16173


普通分类: