Hi, I've got a D7 Views Finder working perfectly except for one problem. The view that feeds this finder includes title, CCK fields, and taxonomy terms. I can successfully search and get results using words from the title or CCK fields, but searching for a term name returns no results.
However, searching for the tid of one of the terms DOES return the correct results based on that tid.
Initially, I tried adding the "All taxonomy terms" to the Views Fields list and to the Finder element's Possible Choices field. I also tried using the field "Keywords" (the name of the vocab in question) and got the same results.
tl;dr: can only search TIDs on my finder, not taxonomy term names. Any suggestions? Thanks!!
Comments
Comment #1
danielb commentedOne way to do this would be for there to be a field on your node which stores the term name. A typical 'term reference' field only stores the tid, which is good for database relations but not so good for human readability. This idea can be implemented using the 'computed field' module which can convert your term reference's tid into a term name.
If your finder element is a select list or radios/checkboxes, then you can use the 'rewrite' setting in finder to convert tid to term name for display purposes (but internally finder will use the tid). This doesn't work so well for autocompletes though - which MUST use the raw value in the textfield (until autocompletes are better http://drupal.org/node/1151136).
Both of the above suggestions require you to write your own PHP to handle the conversion of tid to term.
I'd like to know how Views knows what to display when you use these fields as a filter, maybe we could automate this stuff. If not, perhaps a feature could be added specifically to handle taxonomy terms, or field api fields with key/value pairs, as this issue comes up all the time.
See also
#1283508: 'Display' field option for choices lists
#1283510: Get choices list from another source
Comment #2
danielb commentedA less fun option is to write our own Views filter plugin for term names by vocabulary. I did this in Finder 6.x-1.x, but removed it for the 7.x because the taxonomy stuff has changed too much, but perhaps an equivalent thing could be added. Pretty sure back in Views 5.x-1.x this functionality came with views, but they must have felt it was redundant for their purposes... but it kinda wasn't...
edit: actually I don't think this will work anyway because without the term reference field there isn't a way to relate the node back to the term
Comment #3
JimShady commentedHi Daniel,
Thanks for the quick and helpful response. I'm going to see if I can do this with Custom Search instead, just because we're on a shoestring here. If I do end up doing it in Finder, I'll write up my PHP code and post it here in case it can benefit anyone else.
Thanks again!
Jim
Comment #4
JimShady commentedI did try turning on all the debug and devel stuff on Views to capture the queries in question so we could find out how Views translates from term to tid, but it was late last night and I'm no Views internals whiz so I went to bed :)
Comment #5
danielb commentedNah, what happens in the query is not the question, I know what is supposed to happen in the query to make this work. The question is how does Views know this.
Comment #6
tom-d commentedDid anyone find a solution? I am in the same boat, I need a lot of the features provided by finder module however not being able to search by term name is my main problem.
Comment #7
danielb commentedFor the moment your best option is the computed field module and some php code calling taxonomy_get_term() on the term reference.
I'll try to find a better solution.
Comment #8
danielb commentedHow are you guys relating nodes with taxonomy terms? Using a 'term reference' field?
Comment #9
danielb commentedI got this working now!!! There are new fields/filters added like "Taxonomy: Terms for your mother". Just like in Drupal 6 really. You might have to coax Views into refreshing it's cache first.
Comment #10
danielb commentedComment #11
tom-d commentedAwesome, where are these new fields? I can only find something similar when I change the view type to term which isn't that useful for me. I feel like I'm missing something obvious.
Comment #12
danielb commentedNo they're in the node views, perhaps you don't have the latest code? Make sure the date on the release is after the date of my post #9