Re: How to use Search plugin hook |
Wed, 05 February 2014 12:57 |
|
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?
|
|
Re: How to use Search plugin hook |
Sat, 01 February 2014 01:06 |
|
If it's not documented it's not an official hook.
You are more than welcome to submit a patch to fix it up.
For example, to return something should be as simple as:
list($search_data, $page_pager) = plugin_call_hook('SEARCH', $srch);
|
|
How to use Search plugin hook |
Tue, 21 January 2014 15:06 |
|
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?
|
|