3

I'm using a single view to display some nodes on my site, and I can't figure out how to get it to only override the three content types I want (retreat, location, and teacher) but not all of them. In the contextual filter I specified validation by those types but it seems that's just making it do nothing on nodes of other content types so their content doesn't get shown at all.

I suspect the problem is either in the contextual filter settings and/or the fact that I specified the view's path as /node/% so as to override the normal display.

Attached are my view and the full contextual filter settings. Thanks for any advice!

view contextual filter

2

You cannot do this because your view has now taken over the path "node/%", which is all node pages.

This means that hitting any node page will load your view, not the default Drupal node page and when your view loads, the contextual filter will either show the node if it is one of your 3 selected types, or it will display no results found for any other node type.

You can only override like this if you want to override the same for all nodes.

There are alternatives though, like (in no particular order - an there are almost certainly more ways not listed here):

  • Dang, and I was so close. I've used Panels and Display suite before, but it's a shame to have to add another layer when all I really need is some way to make the View conditional. Thanks for the clarity and suggestions! – R. Durham Aug 15 '15 at 15:03
  • If you don't want to add that complexity then something like the views_embed_view() in your template file would be the easiest and most light weight solution. – rooby Aug 16 '15 at 9:09
2

After brainstorming with a friend, I came up with a wonderfully simple solution. I simply created a block display to my view, and then restricted that block to only display on nodes of the selected type.

I also changed the default display settings of those content types to not show any of the fields. I also could have hidden that content via CSS or other methods.

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.