1

Drupal 7 and views

My issue might be hard to explain but here goes:

What I want:

show all nodes from two content types, that is tagged with their own individual terms.

What I have done so far:

I created a view that should display nodes from content type"names", and content type "name_auto" that is tagged with "job" the two content types, has its own term but the name is the same. (so job and job, could be different, like: bike and carpet)

My filter looks like this: is published AND content type is names, name_auto AND term is job OR term is job

What the issue is now:

the view give me zero results, but, if I remove one of the terms in filter, I get results but only from one of the content types.

I need to get results from both tagged with job from names, and job from names_auto.

Issue simplyfed (bottomline):

This scenario could just as well be content type shoe, tagged with bike, and content type house, tagged with carpet. and then I need all nodes of bike and house, tagged with their own terms.

What i think is wrong:

I think the view looks for the term in both content types, and then when it only find it in the one, it dont display any of them at all. But why does it do that? I have tried to change the order of the filters and nothing works.

I know it would be easier if you could just see the view, but its on a local site, if the view query, or an export dump would help, please let me know :)

I hope I have explained this well and that you understand my problem.

  • What SQL is your view generating? Can you post it up here? – Felix Eve Mar 5 '14 at 15:24
  • @FelixEve The View SQL (the naming are a bit different(danish), but the scenario is the same): pastie.org/8880158 – DuddiMai Mar 6 '14 at 8:04
  • The WHERE bit looks fine so I suspect it's the INNER JOIN that is filtering out all the results. There is a thread here on how to change a LEFT OUTER using hook_views_query_alter. You could maybe try manually altering the query and run it to see if that fixes the problem. Alternatively someone may be along soon with a solution just using the view UI. – Felix Eve Mar 6 '14 at 9:05
  • @FelixEve YES! Thank you - I went along with an answer from the thread you suggested. I simply checked the reduce duplicates checkbox and it converted my INNER JOINs to LEFT JOINs. Thank you for leading me in the right direction :) – DuddiMai Mar 6 '14 at 14:09
  • Glad you got it sorted. As we found a solution between us I've posted our findings as an answer just so this question doesn't sit in the un-answered queue and could be useful if anyone else is experiencing the same issue... – Felix Eve Mar 6 '14 at 14:42
0

Your problem is that your query is using INNER JOINs but you need to be using LEFT JOINS.

As you found in the thread I linked to the easiest solution is to edit your filter criteria and check the reduce duplicates checkbox.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.