Hello,
I've set up the search form on a website, but i've noticed the search finds files that are in the assets folder. I don't really the search to look through these - just the content pages.
Is there a way to do this?
Cheers
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Hello,
I've set up the search form on a website, but i've noticed the search finds files that are in the assets folder. I don't really the search to look through these - just the content pages.
Is there a way to do this?
Cheers
In your _config.php you should have something along the lines of FulltextSearchable::enable() to turn on searching, you can pass an array without 'File' to exclude assets.
FulltextSearchable::enable(array('SiteTree'));
If you're using the default searchform, you should also be able to do something like this:
$form = new SearchForm($this, "SearchForm", $fields, $actions);
...
$form->classesToSearch(array('SiteTree'));
(only classes you can enter are SiteTree and File...)