Elxis CMS Forum

Extensions => Modules => Topic started by: e-isodos on January 21, 2011, 16:32:23

Title: Exclude content items from Search results
Post by: e-isodos on January 21, 2011, 16:32:23
Hi
 Is there a way to exclude content items from search results ?
Title: Re: Exclude content items from Search results
Post by: datahell on January 21, 2011, 23:28:59
Yes you can, but I need more info to reply to you.

You want to exclude specific content items, whole categories, sections, or what?
Give me some more information on what you want to do.
Title: Re: Exclude content items from Search results
Post by: e-isodos on January 22, 2011, 05:58:12

Exclude whole Sections and items (of different sections)
Title: Re: Exclude content items from Search results
Post by: datahell on January 22, 2011, 10:11:51
As the search bot has only the "limit" as parameter to exclude elements you have to modify the bot source code.
Here is an example on how to do it for the sections.

file: mambots/search/sections.searchbot.php

I write a string of comma separated section ids we want to exclude:
$exclude = '1,4,7,12';

I will now add a new line inside the query (with green the new line I just added):
   . "\n AND a.published = '1'"
   . "\n AND a.id NOT IN (".$exclude .")"
   . "\n AND a.access IN (".$my->allowed.")"

That's it!

Do the same for the other search bots.
Title: Re: Exclude content items from Search results
Post by: e-isodos on January 24, 2011, 22:22:13
Thank you,
I will try it and let you know
Title: Re: Exclude content items from Search results
Post by: e-isodos on January 24, 2011, 23:26:33
Is it possible to change the view of search results from being displayed at frontpage to other menu item?
Or if this is not possible (or hard to do) how I can change the header of the frontpage with "if"
Title: Re: Exclude content items from Search results
Post by: e-isodos on January 25, 2011, 00:13:41
The last question was stupid  !!
Just make a menu item ( Component - Search) and the results are at a new page
Title: Re: Exclude content items from Search results
Post by: e-isodos on January 25, 2011, 18:51:45
As the search bot has only the "limit" as parameter to exclude elements you have to modify the bot source code.
Here is an example on how to do it for the sections.

file: mambots/search/sections.searchbot.php

I write a string of comma separated section ids we want to exclude:
$exclude = '1,4,7,12';

I will now add a new line inside the query (with green the new line I just added):
   . "\n AND a.published = '1'"
   . "\n AND a.id NOT IN (".$exclude .")"
   . "\n AND a.access IN (".$my->allowed.")"


Do the same for the other search bots.
That's it!

Doesn't work. I made the same search with your code and without, but the results are just the same (still contains sections I don't want to be resulted.)


Title: Re: Exclude content items from Search results
Post by: seadhna on August 12, 2015, 19:51:10
In Elxis 4.x, this line works, if it helps anyone!    ."\n AND a.catid NOT IN (".$exclude ='8,59,38,39,40,52,54'.")"
The numbers are changed of course to the category IDs specific to your site.