4

I have a bunch of nodes with terms in a certain vocabulary. The vocabulary consists of doctors' specialties, like "Gynecology / Obstetrics". Terms in this vocabulary have a few extra fields:

  • Singular noun form ("Gynecologist / Obstetrician")
  • Plural noun form ("Gynecologists / Obstetricians")
  • URL string ("obgyn")

I have a view that displays all the nodes associated with the term. The view's path is "doctors/specialties/%", and it has a Contextual Filter for the URL String field of the taxonomy term, via a taxonomy Relationship. So when you go to /doctors/specialties/obgyn, you get a page with a heading "Gynecologists / Obstetricians" and then all the content with that term.

This view previously worked perfectly, but at some point something changed, and now it returns 404. The preview in the Views UI just says "No query was run". When I delete the Contextual Filter, it shows all the normal SQL, but when I re-add it, it goes back to "No query was run".

Here's a dump of the view. Can anyone tell me what I'm doing wrong?

1

When you add a contextual filter to a view, the preview should default to 'No query was run.' This is because you have to actually enter a value into the 'preview with contextual filters:' box before hitting preview. Doing this will refresh the preview and consequently show the SQL.

0

I had already flushed caches and reloaded the page twice (yes, I'm positive, and yes, I swear) when I originally asked this question, but at some point my view magically started working again. So I guess I should have just flushed caches and reloaded the page harder.

  • I had the same. Just to prove that I'm not crazy I duplicated the complete view and voila it worked on the new one. No apparent reason the old view's contextual filter did not work. Flushing harder or flushing views cache did not help. No idea but recreating the same view appears to be the only option. – Yuri May 12 '16 at 21:23
  • I just tested another time and found out that the problem appear in my case because my contextual filter was overwriting the default view display one. Clearly a bug in views, but hard to track what causes this.. – Yuri May 12 '16 at 21:32
0

Seemed to be a hidden flag. Choosing Display > Advanced > Contextual Filters > Specify validation criteria

I still had a node type selected. Unchecked node types, then unchecked Specify validation criteria, then save.

Results as expected when previewing with filters.

0

For me this happened because of particular values in the Contextual Filter configuration itself. I had two filters in that section. Both were set 'When the filter value was not present' to 'query'. The query parameter was named, but I couldn't get rid of this message until both filters had the "fallback value" set to all (without a capital A, FWIW).

0

In my case the preview of block with contextual filters worked on a localhost site, then I exported the view into configuration, refreshed my local DB from live, updated to core 8.7.1 from 8.6, re-imported the configuration and the view is fine but the preview no longer works. I have to save and refresh a page where the block appears to preview my changes, which while inconvenient is not a dealbreaker.

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.