Closed (duplicate)
Project:
Drupal core
Version:
7.x-dev
Component:
node.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Nov 2007 at 11:00 UTC
Updated:
9 Apr 2008 at 14:21 UTC
I just talked to a client today who's using several node types internally to store information about users; one of these types is accessible to visitors who browse directly to the page, but tends to spam the search results whenever certain common phrases are searched on.
They need to hide specific node types from the search index, and have been running a patched copy of node.module to accomplish this. I'm not sure there's any way to do this without hacking core currently, so I thought I'd roll a quick patch for it.
| Comment | File | Size | Author |
|---|---|---|---|
| search_skip_types.patch | 1.9 KB | eaton |
Comments
Comment #1
catchThis applies cleanly and works for me. I think it's RTBC but wouldn't hurt to have another set of eyes look over it. With node profile modules etc. this would be a very useful thing to have.
Comment #2
nedjoWe do indeed need the ability to exclude content from search. We can do so currently through tricky uses of
hook_db_rewrite_sql(), but it's clunky due to the non-standard way thatnode_search()invokesdb_rewrite_sql():Another non-patch alternative is a theme override that selectively skips rendering, but again this is clunky.
This patch is a good start, but I see two issues:
1. It doesn't provide flexibility. Often we might wish to filter search presentation by other than node type.
2. The approach skips results after they are loaded. Presumably this means (a) unneeded processing to load the skipped result and (b) the number of results will be incorrect, e.g. twenty results will be loaded but only 17 presented, an issue that will affect pagination as well.
So the case needs some more thought. For now,
hook_db_rewrite_sql()may be our best tool, See the related issue here:http://drupal.org/node/54622, "Stop avoiding db_rewrite_sql() in node_search()". If that covers the case, we can mark this new issue as a duplicate.
Comment #3
eaton commentedAgreed, though I have the feeling that doing so would mean monkeying around much, much deeper in the system than anyone wants to at the moment. I wasn't aware of the sql rewrite approach, but I think that it -- combined with some hook_form_alter magic to keep those content types off the advanced search screen -- should help the client do this without hacking core.
Comment #4
douggreen commentedWith no changes to core today, if you used hook_nodeapi 'search result' and simply set $node to null or something like that, you'd almost get what you want.
Can't you do this with a less intrusive patch by simply adding an argument or changing the returns from hook_nodeapi 'search result'?
Comment #5
robertdouglass commentedRelated patch: http://drupal.org/node/111744
Suggestion from Steven W.: http://drupal.org/node/84962#comment-449632
Comment #6
catchMarking as duplicate of http://drupal.org/node/111744