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

Hide assets/Forms from Site Search Results


Reply


4 Posts   304 Views

Avatar
goodness

Community Member, 38 Posts

4 February 2014 at 5:56am

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!

Avatar
goodness

Community Member, 38 Posts

5 February 2014 at 3:17am

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!

Avatar
Matt

Core Development Team, 84 Posts

5 February 2014 at 11:15am

Edited: 05/02/2014 11:18am

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 [url=http://doc.silverstripe.org/framework/en/trunk/changelogs/2.4.6#security-user-uploaded-files-searchable-when-using-fulltextsearchable]instructions here[/url] 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!): [url]http://sspaste.com/paste/show/52f163516d33b[/url].

Avatar
Matt

Core Development Team, 84 Posts

5 February 2014 at 11:18am

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: [url]https://github.com/silverstripe/silverstripe-framework/blob/3.0/model/MySQLDatabase.php#L842[/url]