0

This answer explains the set up I currently have. I have cloned the Taxonomy Term view built into views, and added some extra filtering etc. To create a depth aware list of nodes for taxonomy terms as linked by pathauto (pattern pub/by/[term:vocabulary]/[term:name]). So for example previously a link to /pub/by/publisher/asian-development-bank would provide me with a list of nodes that had associated Asian Development Bank in a term reference field with the node.

This is site is bilingual, and the publisher vocabulary has an acronym field, and on the node creation form, I needed the autocomplete to return results for the name entered in either English or Japanese, or the acronym.(more detail in this question) Which required me to change the fields referencing the publisher vocabulary to be entity reference fields instead of term reference fields.

The problem is that now /pub/by/publisher/asian-development-bank is an empty list. I'd like to override /path/by/publisher/% links to use an entity reference relationship to search for the term rather than the means that the default Taxonomy Term view does. The issue is that the path in the Taxonomy Term view is /taxonomy/term/% utilizing the value coming from the destination query variable.

How can I create a view that will still use those links generated by pathauto, but actually return results from the entity references?

Just to complicate things a little, each node has two entity reference fields to the publisher vocabulary: field_doc_copyright and field_doc_publisher

  • What do you currently have as contextual filter? – No Sssweat Jul 29 '16 at 22:47
  • The original view has term with depth and term with depth modifier. For this one I don't need the depth, but I've tried different experiments and deleted them. I think these are the primary challenges: getting the view to listen on /pub/by/publisher/% and feed the same argument to two contextual filters one for each field. I have a module for treating contextual filters as OR arguments which probably comes into play there. So I guess the primary thing I don't know how to do is feed one argument to two contextual filters. – UltraBob Jul 29 '16 at 22:57
  • and for "WHEN THE FILTER VALUE IS NOT IN THE URL" what are you using? – No Sssweat Jul 29 '16 at 23:01
  • I can give a better answer Monday when kids aren't climbing all over me, but here is a gist for the view I was last in the middle of building: gist.github.com/UltraBob/6d6f6fb3f2e7f23cb1fefaf24d7d4c98 – UltraBob Jul 29 '16 at 23:32
  • Right now I have display all results for when the value is not in the url. I other words, I don't know what should be there. – UltraBob Jul 31 '16 at 23:59
0

I got it. I had initially been trying to create a new view to operate on the /pub/by/publisher/% path, but I realized by inspecting the view, that the view I already had on /taxonomy/term/% was handling the route because links to one of the pathauto generated routes end up being to the equivalent of /pub/by/publisher/term-name?destination=/taxonomy/term/tid

The problem is then to get the existing view to show the results I want. In my case, since the existing view was showing no results for any publisher vocabulary term, and publisher terms should be the only terms that return results for my new view; I had the option of adding an attachment or other view in the no results section or to just create an attachment attached after the main view. I added an attachment and added it after the main view. Since I needed the results of two entity reference fields I needed an OR condition between my contextual filters. For this I used Views Contextual Filters OR.

One additional problem I faced was that my filters and contextual filters were being joined with an OR condition rather than an AND condition, meaning that I was effectively querying for public nodes or the right type OR the nodes I actually want, which returned way more results than intended. The solution for this, was to add a new empty filter group to my attachment, joined to the original filter group with an AND condition, this caused it to start joining my contextual filters with AND as well.

Finally, my main view had some exposed filters on it, but thought I had inherit exposed filters checked on the attachment, those exposed filters were not working. It turns out that you need to add the same exposed filters to the attachment before the inheritance on them will work.

I doubt many people will have exactly the same problems I had, but hopefully it will provide a clue for people with something similar. As seems to always be the case @no-sssweat was instrumental in providing the hints I needed to get to the answer. Thank You!

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.