FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » How to use Search plugin hook
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
How to use Search plugin hook [message #184718] Tue, 21 January 2014 15:06 Go to next message
wferguss   Canada
Messages: 11
Registered: December 2013
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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 #184767 is a reply to message #184718] Sat, 01 February 2014 01:06 Go to previous messageGo to next message
naudefj is currently offline  naudefj   
Messages: 3624
Registered: December 2004
Karma: 17
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
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);

Re: How to use Search plugin hook [message #184815 is a reply to message #184767] Wed, 05 February 2014 12:57 Go to previous message
wferguss   Canada
Messages: 11
Registered: December 2013
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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?
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: Map BBCode
Next Topic: Proposed fix to ckeditor.plugin
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Oct 18 07:15:00 EDT 2017

Total time taken to generate the page: 0.00774 seconds