0

I am displaying a block of related articles in node page using views. I want to hide a view on node page if certain entity field on this node is empty. My view has contextual filter with default value node nid (relationship to entity ref. field) and relationship to entity reference field. How is it possible to do?
My aim is to show block in sidebar or mail content based on what is in the field (n/a or sidebar for example). Or is there any better way to show that block on various positions of page?

I use context module so I would create views - one for sidebar and second for main page. One would be set to show only if field is empty and the second one opposite. Thank you.

1 Answer 1

0

Just add another filter on the parent node relationship for that current field. Not sure on what field is what for you but it seems you have all the relationships added into the view based on the parent node page?

Just add another filter, select the field you want to check, add the parent node relationship and make sure its NOT EMPTY.

If you just have the contextual filter as a nid, add a relationship to that nid so you can get access to the parents fields.

5
  • Hi, do you mean add another contextual filter? I need to show the blocks based on field on current node not referenced nodes.
    – loparr
    Feb 25, 2013 at 22:43
  • No, not a contextual filter, a regular filter.
    – iLLin
    Feb 25, 2013 at 23:00
  • In my case, regular filter for that field, would only filter referenced nodes (on that nodes there is not the field) The field is on current node.
    – loparr
    Feb 25, 2013 at 23:04
  • Correct, add a relationship and then add the relationship to the field. So its joining the results and providing some extra filtering based on the parent node.
    – iLLin
    Feb 25, 2013 at 23:10
  • 1
    It works, I would have never guessed this solution. Thank you very much,
    – loparr
    Feb 25, 2013 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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