How to use Search plugin hook [message #184718] |
Tue, 21 January 2014 20:06 |
|
wferguss
Messages: 11 Registered: December 2013
Karma: 0
|
Junior Member |
|
|
Keyword search is not adequate for our needs so I would like to write a search plugin. I see that there is a SEARCH hook in search.php.t, but I don't see how I can use it to do my own search. It only takes the search string, none of the other search attributes, and it doesn't return anything. How is this supposed to work?
I also noticed it's not documented on http://cvs.prohost.org/index.php/Plugin#Available_hooks
Is it even real/official/used?
|
|
|
|
Re: How to use Search plugin hook [message #184815 is a reply to message #184767] |
Wed, 05 February 2014 17:57 |
|
wferguss
Messages: 11 Registered: December 2013
Karma: 0
|
Junior Member |
|
|
I ended up adding a hook in a different spot, since all I really needed to do was change how the search_cache table is populated:
/* Remove expired cache entries. */
q('DELETE FROM {SQL_TABLE_PREFIX}search_cache WHERE expiry<'. (__request_timestamp__ - $GLOBALS['SEARCH_CACHE_EXPIRY']));
if (!($total = q_singleval('SELECT count(*) FROM {SQL_TABLE_PREFIX}search_cache WHERE srch_query=\''. $qry_lck .'\' AND query_type='. $qt))) {
if (defined('plugins') && isset($plugin_hooks['UPDATE_SEARCH_CACHE'])) {
plugin_call_hook('UPDATE_SEARCH_CACHE', array($qry_lck, $tbl, $qt, $wa));
} else {
q('INSERT INTO {SQL_TABLE_PREFIX}search_cache (srch_query, query_type, expiry, msg_id, n_match) '.
q_limit('SELECT \''. $qry_lck .'\', '. $qt .', '. __request_timestamp__ .', msg_id, count(*) as word_count FROM {SQL_TABLE_PREFIX}search s INNER JOIN {SQL_TABLE_PREFIX}'. $tbl .' i ON i.word_id=s.id WHERE word IN('. $qr .') GROUP BY msg_id ORDER BY word_count DESC',
500, 0));
}
}
Any chance this could be accepted into the source?
|
|
|