Jump to:

23371 Posts in 18161 Topics by 2865 members

General Questions

SilverStripe Forums » General Questions » Search form :: block 'assets' folder

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

Page: 1
Go to End
Author Topic: 640 Views
  • Futureweb
    Avatar
    Community Member
    232 Posts

    Search form :: block 'assets' folder Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Search form :: block 'assets' folder Link to this post

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

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Search form :: block 'assets' folder Link to this post

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

    640 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.