Think of a filter like this:
-----
Filter criteria

  • Content: Published (Yes) AND
  • Content: Type (= Article)

OR

  • Content: Published (Yes) AND
  • Content: Type (= Basic page) AND
  • Content: Show in newsfeed? (= 1)

-----
(Please excuse any translation problems. My Drupal is in German and I hope I used the correct English phrases.)

As far as I know, the given filter criteria should give you a list of all(!) articles, but only of those basic pages which have the (individually added) check box "Show in newsfeed" ticked.

Unfortunately, only the ticked basic pages but none of the articles are listed in this view. At the time you add the Show-in-newsfeed-criteria to the view, it blocks out every article, although it should not relate to articles at all.

I think, views like that worked fine a couple of weeks ago, but they do not now. So perhaps it is a problem that occurs only with the newer version(s) of the module.

CommentFileSizeAuthor
#4 viewsANDOR.png10.48 KBholtzermann17
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chaloum’s picture

I think you may need to do this

Content: Published (Yes) AND
Content: Type (= Basic page) AND
Content: Show in newsfeed? (= 1)
OR
Content: Published (Yes) AND
Content: Type (= Article)

or perhaps this

Content: Published (Yes) AND
Content: Type (= Basic page, Article) AND
Content: Show in newsfeed? (= 1)

quadratur’s picture

Thanks for your suggestion.

I already tried to change the order but keep the logic of the rules, but that did not work. And because the articles do not have a field named "Show in newsfeed", the latter suggestion shows the same (wrong) result, which means it does not show any article at all.

In this construction:

Content: Published (Yes) AND
Content: Type (= Article)
OR
Content: Published (Yes) AND
Content: Type (= Basic page) AND
Content: Show in newsfeed? (= 1)

it seems that the views module uses the show-in-newsfeed-criteria for the article, although it should NOT do that, because it is a completely different branch of the filter criteria.

A possible workaround for me is to create the same field "Show in newsfeed" within the content type Article and set it to ticked. But this should not be the final solution, because in my opinion, the module mixes up the filter criteria in a completely wrong way.

I think, this is a serious bug.

quadratur’s picture

Another far easier workaround:

No additional field within the content type Article, but the following filter criteria:

Content: Published (Yes) AND
Content: Type (= Article)
Content: Show in newsfeed? (empty)
OR
Content: Published (Yes) AND
Content: Type (= Basic page) AND
Content: Show in newsfeed? (= 1)

This keeps the "Show in newsfeed = 1" strictly away from the articles. (But again there is a problem here, because the order of the rules can lead to different results although the logic stays the same. This, too, makes me think, that there is a big problem within the filter handling.)

Still I think the module should work properly with the filter criteria given in my first comment. At least, similar mysql views (SELECT statements) in other databases work fine that way.

holtzermann17’s picture

FileSize
10.48 KB

I'm also having a very similar problem on Views 7.x-3.4.

The attached screenshot shows: I want items that are either Groups with a given property OR some other specific type. What I end up getting is (apparently) just groups.

I think this is potentially related to another issue I reported which has to do with the way Views generates SQL queries: https://drupal.org/node/1770742

areikiera’s picture

I have exactly the same problem.

Content: Published (Yes) AND
Content: Type (= Article)
OR
Content: Published (Yes) AND
Content: Type (= Basic page) AND
Content: Featured (= Yes)

That view only returns Articles (I have Basic pages marked as Featured; removing the Featured field does allow pages to appear in the view, but unfiltered as needed). Tried the workaround from comment #3, which did not work for me. Without that workaround, it's an even bigger problem. Any updates on this? And is anyone else still experiencing it?

dawehner’s picture

It would be cool if you could enable to show the runned sql (it's under the views settings) and show it here.
This has the advantage that you can easy see, whether this is a problem of the generated sql, thanks.

areikiera’s picture

Definitely! This is for a different example than the one mentioned in my previous comment. The Filter Criteria looks like this in my view:

FIELDS
Content: Title

FILTER CRITERIA
Content: Published (Yes)  AND
Content: Type (= Suggested Itinerary)
OR
Content: Published (Yes)  AND
Content: Type (= "View All _____" page)  AND
Content: Section (= View all Itineraries)

The SQL query is below:

SELECT node.title AS node_title, node.nid AS nid
FROM 
{node} node
INNER JOIN {field_data_field_section} field_data_field_section ON node.nid = field_data_field_section.entity_id AND (field_data_field_section.entity_type = 'node' AND field_data_field_section.deleted = '0')
WHERE (( (node.status = '1') AND (node.type IN  ('suggested_itineraries')) )OR( (node.status = '1') AND (node.type IN  ('view_all_page')) AND (field_data_field_section.field_section_value = 'itineraries') ))

This only shows me data from the second filter group (I definitely have data for both). Thanks!

janvonmulert’s picture

+1

Dean Clayton’s picture

I came across the exact same problem.

Tested the workaround suggested in 3, and i did actually get it to work. As stated, I had to get the ordering of the individual filters correct.
for me it was done as follows:

Content: Published (Yes) AND
Content: Type (= Comic Issue) AND
Content: News type (empty)
OR
Content: Published (Yes) AND
Content: Type (= News) AND
Content: News type (= Latest Site Updates)

When the News type (empty) was before the content type OR in the 2nd group it didn't appear to work.

Doing some searches, this is related to this issue = Many-to-one filters, OR-groups and INNER JOIN, so related them together.

scott.browne’s picture

I see this issue is still active even with the new version. I tried the work around but it only allows for one type to be viewed. The second still appears blank.

ikeigenwijs’s picture

still alive

And
published
promoted to front
Is of Type A,B
And
or Term A of contenttype A
or Term B of contenttype B

Shows nothing (and should)

padinek’s picture

Agreed... still alive, even in 7.x-3.14

SELECT field_data_field_weight.field_weight_value AS field_data_field_weight_field_weight_value, node.nid AS nid, DATE_FORMAT((DATE_ADD('19700101', INTERVAL node.created SECOND) + INTERVAL 7200 SECOND), '%Y%m%d%H%i') AS node_created_minute
FROM 
{node} node
LEFT JOIN {field_data_field_validity} field_data_field_validity ON node.nid = field_data_field_validity.entity_id AND field_data_field_validity.entity_type = 'node'
INNER JOIN {field_data_field_publish_in_news} field_data_field_publish_in_news ON node.nid = field_data_field_publish_in_news.entity_id AND field_data_field_publish_in_news.entity_type = 'node'
LEFT JOIN {field_data_field_publish_in_news} field_data_field_publish_in_news2 ON node.nid = field_data_field_publish_in_news2.entity_id AND field_data_field_publish_in_news2.field_publish_in_news_value != '1'
LEFT JOIN {field_data_field_weight} field_data_field_weight ON node.nid = field_data_field_weight.entity_id AND field_data_field_weight.entity_type = 'node'
WHERE (( (field_data_field_validity.field_validity_value IS NULL ) AND (field_data_field_validity.field_validity_value2 IS NULL ) AND (node.status = '1') AND (node.language IN  ('fr', 'und')) AND (node.type IN  ('news', 'publication')) AND (field_data_field_publish_in_news.field_publish_in_news_value = '1') )OR( (DATE_FORMAT(field_data_field_validity.field_validity_value, '%Y-%m-%d') <= '2016-09-30') AND (DATE_FORMAT(field_data_field_validity.field_validity_value2, '%Y-%m-%d') >= '2016-09-30') AND (node.status = '1') AND (node.language IN  ('fr', 'und')) AND (node.type IN  ('news', 'publication')) AND (field_data_field_publish_in_news2.field_publish_in_news_value = '1') ))
ORDER BY field_data_field_weight_field_weight_value ASC, node_created_minute DESC
LIMIT 10 OFFSET 0

It seems only evaluate the first part of the "where" condition.
Because if I inverse the both parts, I get another result... (and of course, I need both results :D )

padinek’s picture

Version: 7.x-3.5 » 7.x-3.14
padinek’s picture

In relation with my previous comment :

that line :
INNER JOIN {field_data_field_publish_in_news} field_data_field_publish_in_news ON node.nid = field_data_field_publish_in_news.entity_id AND field_data_field_publish_in_news.entity_type = 'node'

If I remove the concerned field filter, the both conditions are well evaluated.
The INNER JOIN was the problem, then ?

martinjmurph’s picture

Still seems an issue for me. However based on the comments in this thread, I seemed to get the results I was after with the following.

Content: Published (Yes) AND
Content: Type (= Report)

OR

Content: Published (Yes) AND
Content: Type (= Article) AND
Content: Publish as a report (not empty)

The inner join seemed to be the problem for me. However with the filters above this did a left join, and as I said is now bringing back the required results for me.

quintard’s picture

Views 7.x-3.18
I have defined 2 new content types : 'News' and 'Report'
content type 'News'
(...)
field type = A,B,C,D,E
field date_news

content type 'Report'
(...)
field date_report

I want to list the News and the Reports of type D or E

in Views - filter criteria I have :
Content: Publish (Yes) AND
Content: Type (= News) AND
Content: Type (not A,not B, not C)
OR
Content: Publish (Yes) AND
Content: Type (= Report) AND

if I write the line as above :
Content: Type (not A, not B, not C) => working fine - the News and Reports are properly displayed.

but if instead I write :
Content: Type (or D, or E) => the news are properly displayed BUT no report displayed.

TomasComsolvia’s picture

I found this issue also. Adding Content: News type (empty) to the first group didn't work.
However, changing the weight of the rows made it work correctly. When I clicked "Show row weight" it was out of order. I rearranged to 1,2,3,4 and all is good! :)

samerjh’s picture

I found a solution in my case where a news-type (String List Field) was one of my conditions, Instead of add condition type is one of (and choose elements); I choose is none of (and choose the opposite). this solved the problem for me

joseph.olstad’s picture