Jump to:

23358 Posts in 17875 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Hide assets/Forms from Site Search Results

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: 193 Views
  • goodness
    Avatar
    Community Member
    38 Posts

    Hide assets/Forms from Site Search Results Link to this post

    Is there a simple way to tell Silverstripe to not include the Forms folder under Assets in local site search results?
    I am using version 3.0.5

    Thanks!

  • goodness
    Avatar
    Community Member
    38 Posts

    Re: Hide assets/Forms from Site Search Results Link to this post

    I'm surprised no one has encountered this before. Perhaps I didn't explain what I'm trying to accomplish very clearly.

    I have PDF files with the path: www.mydomainname.com/assets/Forms/FileName.pdf

    What I want to do is stop the internal site search from showing anything inside the Forms folder in the search results.

    Is anyone able (and willing) to give me specific instructions on how to achieve this?

    Thanks!

  • Matt
    Avatar
    Core Development Team
    84 Posts

    Re: Hide assets/Forms from Site Search Results Link to this post

    Hey goodness,

    There is a 'ShowInSearch' boolean field on the File class already, but it's not surfaced in the Files section of the CMS at the moment. You have two options:

    Option 1: Follow either of the instructions here to disable searching all File objects (or, using the SQL, you could disable searching for only a sub-set of files (by finding the 'ID' of the Forms folder as you mention below, and amending the SQL query).

    Option 2: Add a 'FileExtension' class which surfaces that checkbox, so that for individual files, you can use the CMS to change whether or not you want that file shown in search. That extension class would look something like this (untested, use at your risk!): http://sspaste.com/paste/show/52f163516d33b.

  • Matt
    Avatar
    Core Development Team
    84 Posts

    Re: Hide assets/Forms from Site Search Results Link to this post

    For what it's worth, the code that actually performs the search is specific to the database engine in use. I presume you're using MySQL, so the code that searches by default is here: https://github.com/silverstripe/silverstripe-framework/blob/3.0/model/MySQLDatabase.php#L842

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