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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Search form :: block 'assets' folder


Go to End


3 Posts   1212 Views

Avatar
JonShutt

Community Member, 244 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, 5523 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, 1391 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...)