How to exclude article,category from joomla 1.6,1.7 search results?
Joomla has nice search functionality where we can get search results from any other components like weblinks, categories and any component that supports plug in for this search functionality. We can find a lot of search components and modules that will costomize the search functionality. Even we find a lot of functionality core joomla article search plug in missed a bit features.
- Exclude specific articles from search which are private , module content holders.
- Exclude specific article from categories .
Now we are going to costomize the core Search – Content plug in to exclude particular articles and categories in steps.
Find the Search – Content core joomla plug in.
Go to Administrator => Plug in Manager => Search – Content plug in
Then we will see the following default options on right side of the plug in
- Search Limit – you can limit the search results from the content
- Articles
- Archived Articles

Now go to following folder pluginssearchcontent and you will see following files in this directory.
- index.html
- content.xml
- content.php
Adding Custom parameters for core Joomla search plugin
Now open content.xml file and append the following code to in field list after the field "search_archived".
<field name="search_idlimit" type="text" size="30" default="" label="Exclude Articles" description="Enter Article ID(s) to omit from search. Use commas to separate multiple values."/> <field name="search_seclimit" type="text" size="30" default="" label="Exclude Sections" description="Enter Section ID(s) to omit from search. Use commas to separate multiple values."/> <field name="search_catlimit" type="text" size="30" default="" label="Exclude Categories" description="Enter Category ID(s) to omit from search. Use commas to separate multiple values."/> |
Now you will see three more custom parameters for this joomla search plug in as shown bottom figure.

- In the Exclude articles – fields we can give comma seperated articles ID’s which are not going to to be shown in Joomla search results.
- In the Exclude Section – fields we can give comma seperated Section ID’s which are restricted from the search results.Even Joomla 1.6,1.7 dont have these sections ,i added as backward compatability for Joomla 1.5 .
- In Eclude Categories – also we give the comma seperated categories ID’s to be restricted from the search results .
Customizing the content.php
Add the following code to this content.php file at 105 line after the first switch statement.
$search_idlimit= $this->params->def('search_idlimit', ''); $search_seclimit= $this->params->def('search_seclimit', ''); $search_catlimit= $this->params->def('search_catlimit', ''); if(!empty($search_seclimit)){ $where .= ' AND ( a.sectionid NOT IN ('.$search_seclimit.'))'; } if(!empty($search_catlimit)){ $where .= ' AND ( a.catid NOT IN ('.$search_catlimit.'))'; } if(!empty($search_idlimit)){ $where .= ' AND ( a.id NOT IN ('.$search_idlimit.'))'; } |
from the above code we get each parameters and modify the core plug in sql query if parameters available.
Test the Search result
Now go to administrator =>content=>category manager =>new
create a "sample category1 " and add a sample articles with your choice into this sample category.
add the category id of above category in search plug in options "Exclude Category" ,example 15
now search the result from the front and you can not see this category articles.
Download Files

