Question about the search module
Question about the search module
Search does offer the ability to limit the search results to a specified module which is nice. Now I'm looking for the opposite. Is there a way to exclude a certain or a list of modules to be excluded from the search results?
Re: Question about the search module
It's cheating slightly but you can check in the search results template which module is producing the search result and then chose whether to display it or not.
There's actually an example in the default search results template now I come to look.
Code: Select all
{if $entry->module ne 'YourSecretModule'}
{$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a>
{/if}
Re: Question about the search module
Thanks for the response. Sadly it doesn't really answers the question. The example you are referring to works for the news module. I actually want to limit search to the "content" table (thus the regular pages) but don't know how to call that because it isn't a module is it?
Re: Question about the search module
What the above code does is hide results from 'YourSecretModule'.
So for any modules that you want not to appear in the results you just add them to the conditional.
For example
will not show results from the News or Blog modules. The 'ne' in the smarty tag is 'not equal' so only results that aren't News or Blog get displayed
If you're sure you want to hide results from all modules and only show results from content then you can check to see if the value for module is empty:
So for any modules that you want not to appear in the results you just add them to the conditional.
For example
Code: Select all
{if $entry->module ne 'News' && $entry->module ne 'CGBlog'}
{$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a>
{/if}
If you're sure you want to hide results from all modules and only show results from content then you can check to see if the value for module is empty:
Code: Select all
{if $entry->module == ''}
{$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a>
{/if}