Phone icon for calling web design Call Today:

  • (519) 204-6201 (CA)
  • (612) 594-4495 (cell)

Concerto Designs Minneapolis Joomla Web Design medallion logo

    One of my clients uses FeedGator, a wonderful rss feed component for her large Joomla 2.5 site. Using FeedGaror's integration with K2, we have set up the feeds to display on the home page using the K2 Content Module, which shows an introtext and a "read more" for the first batch of feeds.

    Our challenge has been finding a solution to exclude those feeds from site search results. In a way, the enhanced search capabilities of Joomla 2.5 work a little too well, since indexing the site content makes internal searches extremely accurate and thorough. Displaying news feeds in search results is obviously counterproductive since those links will take visitors off-site. There were some other issues with the default search due in part to the very complex nature of the site functionality (several hundreds of K2 items, Community Builder with all the bells and whistles, Kunena, etc.).

    Judging from the threads in K2 and Joomla forums, there is widespread demand for some kind of K2 category exclusion feature. Our solution requires adding one line of code. Here's how we did it.

    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:

    1. Make a backup of the file
    2. 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.
    3. 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.
    4. 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.