Views Conditional Filter

mikeytown2's picture

I'm well aware of Views Or; I'm looking for something that would do a Conditional Filter. Example:

I have a CCK field called showcase. If there is any node with the showcase field set to TRUE then I only want to display nodes of that type. But if none of my nodes have showcase selected then I would like to ignore this filter to still display nodes in this view. View has a random sort; also using sorting to do filtering doesn't seem like the correct way to do this.

Has anyone created a views plug-in like this?


Views PHP Filter

mikeytown2's picture

Recently discovered this module. Looks like it can do what I need.

Arguments with a default value

tzoscott's picture


I do see why you can not simply set an Argument filter to Content>Showcase, although it might be possible with View Relationships.

If you were using Panels, there are a few paths including raw PHP that evaluates 2 different views, and decides which to display (and actually, something like this could probably work as a Block). Panels Variants can use PHP selection code to choose which variant to display (and 2 variants, each containing a view matching the two types of results you want).

I don't know the benefits of viewsphpfilter, but good locations to put PHP code in are Argument filters and also the General Settings>Header. In either one I think you need to invoke views_get_current_view(), and then you can get or set things in the $view object.