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   726 Views

Avatar
Futureweb

Community Member, 233 Posts

1 September 2011 at 10:53am

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

Forum Moderator, 5513 Posts

3 September 2011 at 8:47pm

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

Forum Moderator, 1132 Posts

4 September 2011 at 3:17am

Edited: 04/09/2011 3:19am

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