By Anonymous (not verified) on
Hi all,
So a picture is worth a 1000 words and I had difficulty explaining exactly what I'm after in the subject line!
http://www.junodownload.com/ has a keyword search in the header. You'll notice you can select which 'field' to search by i.e. All, Artists, Title (release) etc via a drop-down and then input keywords in the text field.
Is this possible in Views? I've been trying to achieve it but have come a little unstuck. So I know the 'fields' are exposed filters but where next?
Any help would be much appreciated,
Thanks,
Steve
Comments
~
After the fields filter, add a filter that looks at the Node body, and contains "any word." Click on expose, then save your View. Please let us know if that works.
Many thanks for the response
Many thanks for the response bwv
Am I right in thinking this will only create an exposed filter which will search node body content? Apologies if this is not the case.
I'm after a drop-down that will allow you to select which filter will be used when making a keyword search as per the http://www.junodownload.com/ search.
No, you can have multiple
No, you can have multiple exposed filters; the way I see it, your above-referenced website has two exposed filters.
For your drupal site, do you have fields to search against? How are they organized (CCK, taxonomy, etc.)?
I have several CCK fields I
I have several CCK fields I would like to search: Artist (CCK taxonomy field), Title (default node field), Label (CCK taxonomy field), Cat (CCK text field) and Genre (CCK taxonomy field).
I know I could create several exposed filters for each field but this would result in a form with a drop-down/keyword for Artist, a drop-down/keyword field for Title, a drop-down/keyword for Label etc, something I have already done for an advanced search page.
What I like about the Juno search is the drop down which lets you select which filter you would like to use for the keyword search.
I don't think the Juno search does have 2 exposed filters it has 5: Artist, Title (release), Title (track), Label and DJ equipment. The search drop-down lets you select which filter to search on.
Since all those CCK fields in
Since all those CCK fields in part comprise the node body, I don't see why an exposed word search filter that I described above would not work. Why don't you try it and see, and let us know what you find.
Hi bwv, As I expected using
As I expected using Node: Body doesn't work because by it's very definition it is 'The actual, full data in the body field; this may not be valid data on all node types.' - it won't take into account additional CCK fields.
One way I could half achieve this is to expose the Taxonomy: Vocabulary filter which in turn would allow a user to select either the Artist, Label or Catalog 'filters'. Unfortunately, this wouldn't include the Title field.
As you can see this is a bit of a stumbling point!
Yes, I see what you are
Yes, I see what you are saying. I forgot that the "body" comprises a very discrete area in the node.
Have you seen this module?
http://drupal.org/project/finder
Perhaps it will work for you.
Interesting, thanks for the
Interesting, thanks for the heads-up. I'll dive in and report back!
Many thanks for your help so far.
Finder
Does finder work for this? Doesn't seem to add any functionality to the "Filter" section of a View...
You need a computed field containing all text to be searched.
Because Views is just a way of constructing database queries, and because CCK fields each have a separate column (or table) in the database, I think the only way to use a single Views filter to text-search multiple fields at once is to add a single (non-displayed) computed field that contains all of the text to search on each node. The Computed Field module (http://drupal.org/project/computed_field) works for this: Just run each of the fields (and/or the node body and title) through
strip_tags()and concatenate them into a big, consolidated text string to be searched (filtered) against.Golden post
5 last years I am developing sites with Drupal. But never noticed the real power of couputed fields!!!
Thanks
DRUPAL development & SEO sollutions in Lithuania
You can do this with
You can do this with http://drupal.org/project/views_or
How does this condense multiple fields into one?
Smithmilner, I've been following this thread to do what the OP first described, and looking at the module views_or, I don't get how this lets there be only one input widget for the filter and a dropdown for the different filters wished to be filtered. Yes, if "All" was selected (if it was like the website the OP linked us to), yes, it would be an "OR", but I don't see how this gives us the desired interface. Can you explain why you picked this module to solve this? Thanks.
Did you manage to solve this Steve?
Steve, checking again to see if you managed to ever do what you wanted with Views and only having one text field to search multiple fields. I have looked at what others have said here, and with all due respect, just feels they didn't even understand the question. Do people who use Views and allow searches really have two separate text field inputs for, example, Title and one for Body? Like you, I hope that they can just enter "XYZ" in ONE field and it will search both Title and Body.
So, anyway, any luck? Did you make a site that does this? Thanks.
Hi Rich, No, never got to the
Hi Rich,
No, never got to the bottom of this. Shame really because like you say, this should be a default option (and it may already exist). Be good if the Drupal community has any thoughts on this.
S
Has anyone found a solution
Has anyone found a solution for this yet? maybe with drupal7?
thx
Here's one solution that will
Here's one solution that will get you really close, very easily. The only thing it doesn't do is present the user a select list for which fields they want to search.
1) Enable core's search module
2) Configure a content type to index (or exclude) specific fields. Do this in the Search sub-tab under Display Fields for a content type. Example: admin/content/node-type/page/display/search
3) Run cron several times, to make sure content gets indexed.
4) In a view, add a filter. Select the Search group. Use "Search: Search Terms". Expose that filter.
At this point, site users have the ability to search the site, using the search index, displayed through your view.
5) Add more filters to limit the search to only specific content types, or other criteria.
[edit: added the Cron step]
Greetings, thanks for your
Greetings, thanks for your answer.
I can't find that page: admin/content/node-type/page/display/search
Do you mean creating a new display mode for search results?
Change "page", to the name of
Change "page", to the name of your node type. If your are working on a node type of "cars", change the path to admin/content/node-type/cars/display/search.
"when the only tool you have is a hammer, all problems start to look like a nail"