1 | |
---|
2 | Views Or allows Views to combine filters with OR and fields with COALESCE. |
---|
3 | |
---|
4 | |
---|
5 | Combining filters or arguments with OR |
---|
6 | -------------------------------------- |
---|
7 | |
---|
8 | By default, each record in a view must match all filters. Sometimes records need |
---|
9 | to be included if they match one or more filters in a list of alternatives. |
---|
10 | Views has the ability to combine filters only with AND. If one filter is false, |
---|
11 | the combined list will be false. Views Or adds the ability to combine blocks of |
---|
12 | filters with OR. If one of the filters in the block is true, the combined block |
---|
13 | will be true. |
---|
14 | |
---|
15 | Views Or provides three filters: |
---|
16 | |
---|
17 | - Begin alternatives |
---|
18 | |
---|
19 | Begins a block of alternative filters. |
---|
20 | |
---|
21 | - Next alternative |
---|
22 | |
---|
23 | Separates alternative filters in an alternatives block. |
---|
24 | |
---|
25 | - End alternatives |
---|
26 | |
---|
27 | Ends a block of alternative filters. |
---|
28 | |
---|
29 | Insert these filters between other filters to create alternatives. For example, |
---|
30 | the following sequence of filters |
---|
31 | |
---|
32 | - Views Or: Begin alternatives = |
---|
33 | - Taxonomy: Term ID = Carrot |
---|
34 | - Views Or: Next alternative = |
---|
35 | - Taxonomy: Term ID = Elephant |
---|
36 | - Views Or: End alternatives = |
---|
37 | |
---|
38 | is equivalent to the following logical expression: |
---|
39 | |
---|
40 | (Taxonomy: Term ID = Carrot) OR (Taxonomy: Term ID = Elephant) |
---|
41 | |
---|
42 | Here is a more advanced example. The following sequence of filters |
---|
43 | |
---|
44 | - Node: Published True |
---|
45 | - Views Or: Begin alternatives = |
---|
46 | - Taxonomy: Term ID = Carrot |
---|
47 | - Node: Type = Forum topic |
---|
48 | - Views Or: Next alternative = |
---|
49 | - Taxonomy: Term ID = Elephant |
---|
50 | - Node: Type = Story |
---|
51 | - Views Or: End alternatives = |
---|
52 | - Node: Post date >= -3 weeks |
---|
53 | |
---|
54 | is equivalent to the following logical expression: |
---|
55 | |
---|
56 | (Node: Published True) AND ( |
---|
57 | (Taxonomy: Term ID = Carrot AND Node: Type = Forum topic) |
---|
58 | OR |
---|
59 | (Taxonomy: Term ID = Elephant AND Node: Type = Story) |
---|
60 | ) AND (Node: Post date >= -3 weeks) |
---|
61 | |
---|
62 | Arguments can be combined in the same way as filters. By default, when arguments |
---|
63 | are combined, the same arguments will be used for both sets of alternatives. So |
---|
64 | if there are two alternative arguments in a block, the view needs to receive |
---|
65 | only one argument. Uncheck "Share arguments" in the "Views Or: Next alternative" |
---|
66 | argument to allow each set of alternatives receive different arguments from the |
---|
67 | URL. |
---|
68 | |
---|
69 | |
---|
70 | Combining fields with COALESCE |
---|
71 | ------------------------------ |
---|
72 | |
---|
73 | When using relationships in a view, the same field may appear multiple times. |
---|
74 | Views Or adds the ability to combine multiple fields into one using the COALESCE |
---|
75 | function. The value of the combined field will be taken from the first field |
---|
76 | which contains a value. |
---|
77 | |
---|
78 | Views Or provides two fields: |
---|
79 | |
---|
80 | - Begin alternatives |
---|
81 | |
---|
82 | Begins a group of alternative fields. |
---|
83 | |
---|
84 | - End alternatives |
---|
85 | |
---|
86 | Ends a group of alternative fields. |
---|
87 | |
---|
88 | Insert other fields between these fields to create a combined field. The title |
---|
89 | and settings of the first field in the group will be used for the combined |
---|
90 | field, even if another field contains the value. |
---|