If we could make the finder strip away the ugly stuff and only display the human readable description for the a filefield, I would be very happy. Excellent for document search. See image; I'm trying to make it say "Document of great value" only.
| Comment | File | Size | Author |
|---|---|---|---|
| views-finder.png | 13.42 KB | perandre |
Comments
Comment #1
danielb commentedAs far as finder goes, it's doing it's job in showing the value of the field. The problem you're facing is along the same lines as people using date fields seeing a unix timestamp instead of a nicely formatted date, or using a field that just stores a boolean value. In your case the field contains serialized data (you can use the php unserialize() function to turn it into an array that you can then access). There are probably all kinds of situations where you would want to 'rewrite' the value of the field in order to display it to the user. You can do that with theme functions for the autocomplete suggestions, and the optionwidgets display value, and even through the interface for optionwidgets elements in the latest dev release. However the complication is that for something like an autocomplete the key value has to be the actual value you want to search in the database - unless we find some way of tracking a third value to use instead for the queries - unless you know what you're doing and, for example, you are using a 'contains' match for the results page as well, etc...
My goal is to make it easier to be able to rewrite your own values, and then perhaps package some preset rewrites for stuff like this - it seems like it would be pretty easy for optionwidgets, but not quite straightforward for autocompletes :/ Although I have seen at least one patch in the Drupal issue queue to allow autocompletes to track a value that is unseen by the user - that would go a long way to making it very easy to do in finder.
It may also be worth seeing if Views can tell us how to format a particular field using the views plugins people have written for their fields.
I do know that what you are doing is possible with a bit of programming work to hook into finder at various points and using themes.
It is also be possible to tremendously simplify all of this by creating a CCK 'computed field' that calculates and stores the desired display output based on the file data, and using that computed field instead of the filefield to do the finder stuff. That is a bit of a goofy workaround though as the data will be stored twice - but seriously who gives a toss, it will make it a lot easier to implement and it will work much faster than rewriting hundreds of values on the fly during a search.
Comment #2
perandre commentedThanks for your input!
I stumbled on to something similar wanting to use descriptions from filefield in views. It was solved in a later update by pulling data from Content: Field name (field_name) - data. Is it possible to just use this logic from Views with Finder?
Comment #3
danielb commentedI don't quite know what you mean, probably not. You could also use the computed field for that I'm guessing, you'd just need to figure out the right PHP to put in the computed field.