views:

45

answers:

1

I have created an "Add Question" content-type node which lets users ask questions. The questions have a title, image attachment option, and the content.

I am showing the questions which have image as a block by filtering it as "Content: Photofield - list True" in Views. This way, only the questions which have images attached to the question appear in this block. Photofield by the way is the content type.

I want to create a new block which only shows the questions which have no attached image. I have done filtering this block view by keeping filters as "Content: Photofield - list False" but in vain.

There's also some expose option and I did some messing around with it too without coming to the result I want.

Can anyone help?

+1  A: 

The "Content: Photofield - list" filter only applies to nodes with an attached image, because it is filtering by the value of the "List" option (which only exists if there's an image). If the node has no attachment, this filter won't do anything.

As fas as I know, you'll need to either implement hook_views_query_alter() to add an WHERE clause to the View's query or programatically test if the node have an image in a view template.

Vinicius Pinto
Sounds like your suggestion to use `hook_views_query_alter()` is the best option in this case. Here's the documentation [http://drupalcontrib.org/api/function/hook_views_query_alter/6](http://drupalcontrib.org/api/function/hook_views_query_alter/6).
Erik Töyrä

related questions