Question about the search module

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
gdur
Forum Members
Forum Members
Posts: 142
Joined: Sun Jan 10, 2010 10:59 am

Question about the search module

Post by gdur »

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?
scooper
Forum Members
Forum Members
Posts: 242
Joined: Fri Dec 09, 2005 12:36 pm

Re: Question about the search module

Post by scooper »

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.

Code: Select all

{if $entry->module ne 'YourSecretModule'}
{$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a>
{/if}
There's actually an example in the default search results template now I come to look.
gdur
Forum Members
Forum Members
Posts: 142
Joined: Sun Jan 10, 2010 10:59 am

Re: Question about the search module

Post by gdur »

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?
scooper
Forum Members
Forum Members
Posts: 242
Joined: Fri Dec 09, 2005 12:36 pm

Re: Question about the search module

Post by scooper »

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

Code: Select all

{if $entry->module ne 'News' && $entry->module ne 'CGBlog'}
	{$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a>
{/if}
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:

Code: Select all

{if $entry->module == ''}
	{$entry->title} - <a href="{$entry->url}">{$entry->urltxt}</a>
{/if}
Post Reply

Return to “CMSMS Core”