Hi - is there a way to use nested logic in filters? In terms of boolean logic, if you've got five filters added then they are all evaluated in sequence at the same level of hierarchy, like this boolean logic statement:

a*b*c*d*e

NOTE: * = AND + = OR

I've got a need to do nested logic at different levels of hierarchy, like this:

(a*b) + (c*d*e)

Specifically, my front page is a view. It contains many content types: 'event' (a custom type that uses date fields and some other stuff), blog entry, story, and webform. (So in terms of the boolean logic above, one of the five terms is the filter that says 'Node:type is one of event,blog,story,webform')

Thing is, I only want to show the events that have not happened yet. The event type has a field that I can filter on, content:field_end_date - BUT if I make a filter that says 'content:field_end_date <= now' then this filter becomes just another one of the ANDed terms in the a*b*c*d*e case. The result: since only the 'event' type even has the content:field_end_date field, then, the other types that do not have that field do not show at all. In other words, if you look at a blog entry, which has no such thing as content:field_end_date, then that filter term becomes a zero and therefore the entire filter function never returns and blog entries. or stories or webforms.

But if you could put it in some more complex logic like (a*b)+(c*d*e) then we'd be good:
if ((node:type==event AND content:field_end_date<=now) OR (node:type is on of blog,story,webform AND published AND this AND that AND the other)) then {view}

So, I've seen the 'views or' module but does that completely address things? We want to take two (or more) groups of ANDed filters, go thru them separately, then take those results and OR them together. Seems like the only thorough solution would be to let the user specify the filter function in some graphical manner...

Any help would be greatly appreciated... THANKS!

Comments

figover’s picture

Have you tried views_or module ?

http://drupal.org/project/views_or

caver456’s picture

I did look thru views_or - the node it references kind of indicates that there are plans to do all this in views 3? But it looks like views_or will only allow

(a+b)*(c+d)

whereas I'd need

(a*b)+(c*d)

or at least that's what is implied. Let me know if that's not the case. Thanks

figover’s picture

Views Or supports both (a+b)*(c+d) and (a*b)+(c*d)

If u need any working example, i can also make it for u.

caver456’s picture

Hm, I didn't get that from the views_or description - I'll download and give it a shot tonight but an example would be good too - thanks

dawehner’s picture

Status: Active » Fixed

So this is fixed.

caver456’s picture

Yes, it looks like it's working - thanks

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.