I've massively rewritten the module and I through that I would share.

This version is configurable for:

Block action - keystroke on / off, optional submit button (action is ajax + same page with JScript disabled or faq page submit action [useless by itself but I needed the filter on the FAQ page too - a much messier job including menu alter hooks & faq_page rewrite]

Limit on results returned from 1 to 25 results

Format display options on the results - links, Q & A, Q as link & A

An optional view all link on the block

Also found a couple security issues, the body should now be run through the check_markup() function and the title / question needs to be run through check_plain() or l().

Also hopefully made it domain independent, so the base path can be something other than just '/'.

Moved includes to a hook_init to help avoid caching issues. Also made the block non-caching as it is a trivial block and caching could cause unpredictable results.

Minor coding issues

Sorry for the massive hit rather than multiple independent feature requests, but the project is already overdue and I'm going hard out to meet the requirements.

Hope you enjoy

CommentFileSizeAuthor
#4 faq_search.zip15.92 KBalan d.
#2 faq_search.zip15.36 KBalan d.
#1 faq_search.zip15.1 KBalan d.

Comments

alan d.’s picture

StatusFileSize
new15.1 KB

Forgot the zip :)

alan d.’s picture

StatusFileSize
new15.36 KB

Added prefix options to both Q & A and theming functions for each to handle these and sensitization issues.

alan d.’s picture

Duh: "sensitization" was meant to be "sanitation".

Couple more features / bug fixes

Ordering now mimics FAQ module
Query uses db_rewrite_sql()
Option to show top xxx results when an empty string is added
Option to show top xxx results when the block is loaded

Happy to help maintain if you are interested, but after a couple solid weeks work here in Springsdale, Utah, USA, I'm back on the road towards Central & South America

alan d.’s picture

StatusFileSize
new15.92 KB
mstrelan’s picture

Alan - in the function faq_search_query() you call db_query_range but without the $count and $from parameters, therefore it only ever returns 1 result.

Updated code as follows:

<?php
  if ($default_sorting != 'DESC') {
    $result = db_query_range(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n JOIN {node_revisions} nr ON nr.vid = n.vid LEFT JOIN {faq_weights} w ON w.nid = n.nid JOIN {faq_questions} fq ON fq.vid = n.vid WHERE n.type='faq' AND n.status = 1 AND (w.tid = 0 OR w.tid IS NULL) {$search_sql} ORDER BY weight, n.sticky DESC, n.created ASC", "n", "nid"), $search_args, 0, $settings['limit']);
  }
  else {
    $result = db_query_range(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n JOIN {node_revisions} nr ON nr.vid = n.vid LEFT JOIN {faq_weights} w ON w.nid = n.nid JOIN {faq_questions} fq ON fq.vid = n.vid WHERE n.type='faq' AND n.status = 1 AND (w.tid = 0 OR w.tid IS NULL) {$search_sql} ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $search_args, 0, $settings['limit']);
  }
?>
bensnyder’s picture

admin, please grant Alan D. co-maintainership of this module.

Alan, thank you for your efforts and I apologize for being so delinquent. Just point an admin to this post and they'll do the rest.

alan d.’s picture

Cool, thanks, but I'm traveling in the Americas for another 7 months, so I really will not have the time at the moment. Great to know that you like the new features.

Cheers
Alan

bensnyder’s picture

Status: Active » Closed (fixed)

COMMITTED #4 & #5. Thanks guys!