After trying a number of search options, we wound up using Acesearch, a modestly-priced, commercial search component (we also bought their K2 plugin). Acesearch works very well indeed, and styling it up to match our hand-coded template look and feel was a snap. Although backend parameters do not have an option excluding K2 categories, the solution involves adding one line of code.
As always in this kind of revision (aka a hack), you should:
- Make a backup of the file
- Open a Notepad or TextEdit document and make notes of what you did - this is important because the next upgrade of Acesearch plugin will wipe out any revisions.
- Normally, it'as a good idea to backup the site using the Akeeba backup component (I recommend buying Akeeba Pro - it's an essential tool in my site management). In this case, the functionality of the revised code is limited to searching, so no global impact is likely.
- Keep both front- and back-end views of the site open in separate browser tabs so you can test the results.
The next step is to make a note of the K2 category IDs you want to exclude - you need the category ID number, not the name.
Now you are ready! In your site directory, using your favorite code editor or else Extplorer, open: adminisrtator/components/com_acesearch/extensions/com_k2.php
Go to line 53 where you will see the following code:
if ($this->site) {
$where[] = 'a.published = 1';
$where[] = 'a.trash = 0';
Now add this code immediately below:
$where[] = 'NOT a.catid = 12';
NOTE: you will need to change the value of '12' used in the above example to your own excluded K2 category ID or IDs - for multiple ids, you use a slightly different syntax: 'NOT a.catid = (1 OR 2 OR 3)' etc. If search results are not working as expected, you can also vary the syntax to include only specific categories, e.g. a.catid = (1,2,3) etc.