Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Search form :: block 'assets' folder


Reply

3 Posts   666 Views

Avatar
Futureweb

1 September 2011 at 10:53am Community Member, 233 Posts

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

Avatar
Willr

3 September 2011 at 8:47pm Forum Moderator, 5511 Posts

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'));

Avatar
martimiz

4 September 2011 at 3:17am (Last edited: 4 September 2011 3:19am), Forum Moderator, 1095 Posts

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...)