简体   繁体   中英

A question about Drupal Node and Views

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM